Skip to content

Commit ccac9e8

Browse files
committed
createTag() and listTags() methods added
1 parent fa3e679 commit ccac9e8

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

src/main/java/org/scm4j/vcs/api/IVCS.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Set;
55

66
import org.scm4j.vcs.api.exceptions.EVCSFileNotFound;
7+
import org.scm4j.vcs.api.exceptions.EVCSTagExists;
78
import org.scm4j.vcs.api.workingcopy.IVCSWorkspace;
89

910
public interface IVCS {
@@ -44,4 +45,8 @@ public interface IVCS {
4445
VCSCommit getHeadCommit(String branchName);
4546

4647
Boolean fileExists(String branchName, String filePath);
48+
49+
VCSTag createTag(String branchName, String tagName, String tagMessage) throws EVCSTagExists;
50+
51+
List<VCSTag> getTags();
4752
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package org.scm4j.vcs.api;
2+
3+
public class VCSTag {
4+
private final String tagName;
5+
private final String tagMessage;
6+
private final String author;
7+
private final VCSCommit relatedCommit;
8+
9+
public VCSTag(String tagName, String tagMessage, String author, VCSCommit relatedCommit) {
10+
this.tagName = tagName;
11+
this.tagMessage = tagMessage;
12+
this.author = author;
13+
this.relatedCommit = relatedCommit;
14+
}
15+
16+
public String getTagName() {
17+
return tagName;
18+
}
19+
20+
public String getTagMessage() {
21+
return tagMessage;
22+
}
23+
24+
public String getAuthor() {
25+
return author;
26+
}
27+
28+
public VCSCommit getRelatedCommit() {
29+
return relatedCommit;
30+
}
31+
32+
@Override
33+
public String toString() {
34+
return "VCSTag [tagName=" + tagName + ", tagMessage=" + tagMessage + ", author=" + author + ", relatedCommit="
35+
+ relatedCommit + "]";
36+
}
37+
38+
@Override
39+
public int hashCode() {
40+
final int prime = 31;
41+
int result = 1;
42+
result = prime * result + ((author == null) ? 0 : author.hashCode());
43+
result = prime * result + ((relatedCommit == null) ? 0 : relatedCommit.hashCode());
44+
result = prime * result + ((tagMessage == null) ? 0 : tagMessage.hashCode());
45+
result = prime * result + ((tagName == null) ? 0 : tagName.hashCode());
46+
return result;
47+
}
48+
49+
@Override
50+
public boolean equals(Object obj) {
51+
if (this == obj)
52+
return true;
53+
if (obj == null)
54+
return false;
55+
if (getClass() != obj.getClass())
56+
return false;
57+
VCSTag other = (VCSTag) obj;
58+
if (author == null) {
59+
if (other.author != null)
60+
return false;
61+
} else if (!author.equals(other.author))
62+
return false;
63+
if (relatedCommit == null) {
64+
if (other.relatedCommit != null)
65+
return false;
66+
} else if (!relatedCommit.equals(other.relatedCommit))
67+
return false;
68+
if (tagMessage == null) {
69+
if (other.tagMessage != null)
70+
return false;
71+
} else if (!tagMessage.equals(other.tagMessage))
72+
return false;
73+
if (tagName == null) {
74+
if (other.tagName != null)
75+
return false;
76+
} else if (!tagName.equals(other.tagName))
77+
return false;
78+
return true;
79+
}
80+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.scm4j.vcs.api.exceptions;
2+
3+
public class EVCSTagExists extends EVCSException {
4+
5+
private static final long serialVersionUID = -37435263364256223L;
6+
7+
public EVCSTagExists(Exception e) {
8+
super(e);
9+
}
10+
11+
}

0 commit comments

Comments
 (0)