56 lines
1.9 KiB
Java
56 lines
1.9 KiB
Java
package tk.antoine_roux.wiki.model.request;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import tk.antoine_roux.wiki.model.request.secondary.Commit;
|
|
import tk.antoine_roux.wiki.model.request.secondary.Repository;
|
|
import tk.antoine_roux.wiki.model.request.secondary.User;
|
|
|
|
import java.util.List;
|
|
|
|
public class HookEvent {
|
|
public String secret;
|
|
public String ref;
|
|
public String before;
|
|
public String after;
|
|
@JsonProperty("compare_url")
|
|
public String compareUrl;
|
|
public List<Commit> commits;
|
|
@JsonProperty("head_commit")
|
|
public String headCommit;
|
|
public Repository repository;
|
|
public User pusher;
|
|
public User sender;
|
|
|
|
// AtomicInteger idIncrementer = new AtomicInteger();
|
|
//
|
|
// /**
|
|
// * convert {@link HookEvent} to {@link Job} if possible
|
|
// * else return and {@link Optional#empty()}
|
|
// */
|
|
// public Optional<Job> toJob() {
|
|
// Optional<Job> optJob;
|
|
//
|
|
// if (this.commits.isEmpty()) {
|
|
// optJob = Optional.empty();
|
|
// } else {
|
|
// // search for head commit or take first in event's list of commit
|
|
// Commit commit = this.commits.stream().filter(co -> co.id.equals(this.headCommit))
|
|
// .findFirst().orElse(this.commits.get(0));
|
|
//
|
|
// Job.Commit co = new Job.Commit(
|
|
// commit.author.email, commit.author.name, commit.timestamp,
|
|
// commit.id, commit.message, commit.id.substring(0, 8), commit.message
|
|
// );
|
|
//
|
|
// Job job = new Job(
|
|
// null, co, null, ZonedDateTime.now(), null,
|
|
// this.idIncrementer.getAndIncrement(), UUID.randomUUID().toString(), this.ref,
|
|
// null, "root", null, JobStatus.CREATED, false, this.pusher.toReducedUser()
|
|
// );
|
|
// optJob = Optional.of(job);
|
|
// }
|
|
//
|
|
// return optJob;
|
|
// }
|
|
}
|