-
Notifications
You must be signed in to change notification settings - Fork 401
/
Copy pathGitHubPushCause.java
63 lines (53 loc) · 1.69 KB
/
GitHubPushCause.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.cloudbees.jenkins;
import hudson.triggers.SCMTrigger.SCMTriggerCause;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import static java.lang.String.format;
import static org.apache.commons.lang3.StringUtils.trimToEmpty;
/**
* UI object that says a build is started by GitHub post-commit hook.
*
* @author Kohsuke Kawaguchi
*/
public class GitHubPushCause extends SCMTriggerCause {
/**
* The name of the user who pushed to GitHub.
*/
private String pushedBy;
/**
* The target ref of the triggering GitHub push.
*/
private String ref;
public GitHubPushCause(String pusher, String ref) {
this("", pusher, ref);
}
public GitHubPushCause(String pollingLog, String pusher, String ref) {
super(pollingLog);
this.pushedBy = pusher;
this.ref = ref;
}
public GitHubPushCause(File pollingLog, String pusher, String ref) throws IOException {
super(pollingLog);
this.pushedBy = pusher;
this.ref = ref;
}
@Override
public String getShortDescription() {
return format("Started by GitHub push to %s by %s", trimToEmpty(ref), trimToEmpty(pushedBy));
}
@Override
public boolean equals(Object o) {
return o instanceof GitHubPushCause
&& Objects.equals(this.pushedBy, ((GitHubPushCause) o).pushedBy)
&& Objects.equals(this.ref, ((GitHubPushCause) o).ref)
&& super.equals(o);
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 89 * hash + Objects.hash(this.pushedBy);
hash = 89 * hash + Objects.hash(this.ref);
return hash;
}
}