Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from MarkEWaite/add-getTags
[JENKINS-45447] Add GitClient.getTags()
- Loading branch information
Showing
12 changed files
with
353 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package hudson.plugins.git; | ||
|
||
import org.eclipse.jgit.lib.ObjectId; | ||
import org.eclipse.jgit.lib.ObjectIdRef; | ||
import org.eclipse.jgit.lib.Ref; | ||
|
||
import org.junit.Test; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.*; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
|
||
public class BranchTest { | ||
|
||
private final String branchSHA1; | ||
private final String branchName; | ||
private final ObjectId branchHead; | ||
private final Branch branch; | ||
private final String refPrefix; | ||
private final Ref branchRef; | ||
private final Branch branchFromRef; | ||
|
||
public BranchTest() { | ||
this.branchSHA1 = "fa71f704f9b90fa1f857d1623f3fe33fa2277ca9"; | ||
this.branchName = "origin/master"; | ||
this.branchHead = ObjectId.fromString(branchSHA1); | ||
this.refPrefix = "refs/remotes/"; | ||
this.branchRef = new ObjectIdRef.PeeledNonTag(Ref.Storage.NEW, refPrefix + branchName, branchHead); | ||
this.branch = new Branch(branchName, branchHead); | ||
this.branchFromRef = new Branch(branchRef); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
assertThat(branch.toString(), is(branchFromRef.toString())); | ||
} | ||
|
||
@Test | ||
public void testToString_Contents() { | ||
String expected = "Branch " + branchName + "(" + branchSHA1 + ")"; | ||
assertThat(branch.toString(), is(expected)); | ||
} | ||
|
||
@Test | ||
public void hashCodeContract() { | ||
assertThat(branch, is(branchFromRef)); | ||
assertThat(branch.hashCode(), is(branchFromRef.hashCode())); | ||
} | ||
|
||
@Test | ||
public void constructorRefArgStripped() { | ||
Ref ref = new ObjectIdRef.PeeledNonTag(Ref.Storage.LOOSE, refPrefix + branchName, branchHead); | ||
Branch strippedBranch = new Branch(ref); | ||
assertThat(strippedBranch.getName(), is(branchName)); | ||
} | ||
|
||
@Test | ||
public void equalsContract() { | ||
EqualsVerifier.forClass(Branch.class) | ||
.usingGetClass() | ||
.withRedefinedSuperclass() | ||
.verify(); | ||
} | ||
} |
Oops, something went wrong.