use of com.google.gitiles.RevisionParser.Result in project gitiles by GerritCodeReview.
the class RevisionParserTest method parseTag.
@Test
public void parseTag() throws Exception {
RevCommit master = repo.branch("master").commit().create();
RevTag masterTag = repo.update("refs/tags/master-tag", repo.tag("master-tag", master));
RevTag masterTagTag = repo.update("refs/tags/master-tag-tag", repo.tag("master-tag-tag", master));
assertThat(parser.parse("master-tag")).isEqualTo(new Result(new Revision("master-tag", masterTag, OBJ_TAG, master, OBJ_COMMIT)));
assertThat(parser.parse("master-tag-tag")).isEqualTo(new Result(new Revision("master-tag-tag", masterTagTag, OBJ_TAG, master, OBJ_COMMIT)));
RevBlob blob = repo.update("refs/tags/blob", repo.blob("blob"));
RevTag blobTag = repo.update("refs/tags/blob-tag", repo.tag("blob-tag", blob));
assertThat(parser.parse("blob")).isEqualTo(new Result(Revision.peeled("blob", blob)));
assertThat(parser.parse("blob-tag")).isEqualTo(new Result(new Revision("blob-tag", blobTag, OBJ_TAG, blob, OBJ_BLOB)));
}
use of com.google.gitiles.RevisionParser.Result in project gitiles by GerritCodeReview.
the class RevisionParserTest method nonVisibleDiffShas.
@Test
public void nonVisibleDiffShas() throws Exception {
RevCommit other = repo.commit().create();
RevCommit master = repo.branch("master").commit().create();
assertThat(parser.parse("other..master")).isNull();
assertThat(parser.parse("master..other")).isNull();
repo.branch("other").update(other);
assertThat(parser.parse("other..master")).isEqualTo(new Result(Revision.peeled("master", master), Revision.peeled("other", other), ""));
assertThat(parser.parse("master..other")).isEqualTo(new Result(Revision.peeled("other", other), Revision.peeled("master", master), ""));
}
use of com.google.gitiles.RevisionParser.Result in project gitiles by GerritCodeReview.
the class RevisionParserTest method parseCommitShaVisibleFromChange.
@Test
public void parseCommitShaVisibleFromChange() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.commit().parent(parent).create();
repo.branch("master").commit().create();
repo.update("refs/changes/01/0001", commit);
// Matches exactly.
assertThat(parser.parse(commit.name())).isEqualTo(new Result(Revision.peeled(commit.name(), commit)));
// refs/changes/* is excluded from ancestry search.
assertThat(parser.parse(parent.name())).isNull();
}
use of com.google.gitiles.RevisionParser.Result in project gitiles by GerritCodeReview.
the class RevisionParserTest method parseCommitShaVisibleFromOther.
@Test
public void parseCommitShaVisibleFromOther() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.commit().parent(parent).create();
repo.branch("master").commit().create();
repo.update("refs/tags/tag", repo.tag("tag", repo.commit().create()));
repo.update("refs/meta/config", commit);
assertThat(parser.parse(commit.name())).isEqualTo(new Result(Revision.peeled(commit.name(), commit)));
assertThat(parser.parse(parent.name())).isEqualTo(new Result(Revision.peeled(parent.name(), parent)));
}
use of com.google.gitiles.RevisionParser.Result in project gitiles by GerritCodeReview.
the class RevisionParserTest method parseCommitShaVisibleFromHead.
@Test
public void parseCommitShaVisibleFromHead() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.branch("master").commit().parent(parent).create();
assertThat(parser.parse(commit.name())).isEqualTo(new Result(Revision.peeled(commit.name(), commit)));
assertThat(parser.parse(parent.name())).isEqualTo(new Result(Revision.peeled(parent.name(), parent)));
String abbrev = commit.name().substring(0, 6);
assertThat(parser.parse(abbrev)).isEqualTo(new Result(Revision.peeled(abbrev, commit)));
}