Skip to content

Commit c183e14

Browse files
authored
BI-560 - Add branch to Vcs (#448)
1 parent 1586b4d commit c183e14

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

build-info-api/src/main/java/org/jfrog/build/api/Vcs.java

+21-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
@XStreamAlias(BuildInfoFields.VCS)
1111
public class Vcs implements Serializable {
1212
private String revision = "";
13+
private String branch = "";
1314
private String url = "";
1415

1516
public Vcs() {
@@ -20,6 +21,11 @@ public Vcs(String vcsUrl, String vcsRevision) {
2021
this.setRevision(vcsRevision);
2122
}
2223

24+
public Vcs(String vcsUrl, String vcsRevision, String branch) {
25+
this(vcsUrl, vcsRevision);
26+
this.branch = branch;
27+
}
28+
2329
public String getRevision() {
2430
return revision;
2531
}
@@ -28,6 +34,14 @@ public void setRevision(String revision) {
2834
this.revision = revision;
2935
}
3036

37+
public String getBranch() {
38+
return branch;
39+
}
40+
41+
public void setBranch(String branch) {
42+
this.branch = branch;
43+
}
44+
3145
public String getUrl() {
3246
return this.url;
3347
}
@@ -38,7 +52,8 @@ public void setUrl(String url) {
3852

3953
@Override
4054
public String toString() {
41-
return "revision= '" + revision + '\'' +
55+
return "revision='" + revision + '\'' +
56+
", branch='" + branch + '\'' +
4257
", url='" + url + '\'';
4358
}
4459

@@ -52,18 +67,18 @@ public boolean equals(Object o) {
5267
}
5368

5469
Vcs that = (Vcs) o;
55-
return Objects.equals(revision, that.revision) && Objects.equals(url, that.url);
70+
return Objects.equals(revision, that.revision) &&
71+
Objects.equals(branch, that.branch) &&
72+
Objects.equals(url, that.url);
5673
}
5774

5875
@Override
5976
public int hashCode() {
60-
int result = (revision != null ? revision.hashCode() : 0);
61-
result = 31 * result + (url != null ? url.hashCode() : 0);
62-
return result;
77+
return Objects.hash(revision, branch, url);
6378
}
6479

6580
@JsonIgnore
6681
public boolean isEmpty() {
67-
return StringUtils.isEmpty(this.getRevision()) && StringUtils.isEmpty(this.getUrl());
82+
return StringUtils.isEmpty(getRevision()) && StringUtils.isEmpty(getBranch()) && StringUtils.isEmpty(getUrl());
6883
}
6984
}

build-info-api/src/test/java/org/jfrog/build/api/BuildTest.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626

2727
import java.text.ParseException;
2828
import java.text.SimpleDateFormat;
29-
import java.util.ArrayList;
30-
import java.util.Arrays;
31-
import java.util.Date;
32-
import java.util.List;
33-
import java.util.Properties;
29+
import java.util.*;
3430

3531
import static org.testng.Assert.*;
3632

@@ -79,9 +75,7 @@ public void testSetters() {
7975
String url = "mitz";
8076
String parentName = "pooh";
8177
String parentNumber = "5";
82-
List<Vcs> vcsList = Arrays.asList(
83-
new Vcs(url, "2421")
84-
);
78+
List<Vcs> vcsList = Collections.singletonList(new Vcs(url, "2421", "main"));
8579

8680
List<Module> modules = new ArrayList<>();
8781
List<PromotionStatus> statuses = new ArrayList<>();

0 commit comments

Comments
 (0)