use of com.gitblit.models.TicketModel in project gitblit by gitblit.
the class TicketReferenceTest method commitTicketBranchNoUnexpectedReference.
@Test
public void commitTicketBranchNoUnexpectedReference() throws Exception {
setPatchsetAvailable(false);
TicketModel a = ticketService.createTicket(repo, newTicket("commitTicketBranchNoUnexpectedReference-A"));
String branchName = String.format("ticket/%d", a.number);
git.checkout().setCreateBranch(true).setName(branchName).call();
makeCommit("commit for 1 - no reference");
makeCommit("commit for # - no reference");
final String message = "commit for #999 - ignores invalid reference";
final RevCommit revCommit1 = makeCommit(message);
final String commit1Sha = revCommit1.name();
assertPushSuccess(commit1Sha, branchName);
a = ticketService.getTicket(repo, a.number);
assertFalse(a.hasReferences());
}
use of com.gitblit.models.TicketModel in project gitblit by gitblit.
the class TicketReferenceTest method commitTicketBranchSelfReference.
@Test
public void commitTicketBranchSelfReference() throws Exception {
setPatchsetAvailable(false);
TicketModel a = ticketService.createTicket(repo, newTicket("commitTicketBranchSelfReference-A"));
String branchName = String.format("ticket/%d", a.number);
git.checkout().setCreateBranch(true).setName(branchName).call();
final String message = String.format("commit for #%d - patchset self reference", a.number);
final RevCommit revCommit1 = makeCommit(message);
final String commit1Sha = revCommit1.name();
assertPushSuccess(commit1Sha, branchName);
a = ticketService.getTicket(repo, a.number);
assertTrue(a.hasReferences());
List<Reference> cRefA = a.getReferences();
assertNotNull(cRefA);
assertEquals(1, cRefA.size());
assertNull(cRefA.get(0).ticketId);
assertEquals(commit1Sha, cRefA.get(0).hash);
}
use of com.gitblit.models.TicketModel in project gitblit by gitblit.
the class TicketReferenceTest method commitTicketBranchMultiCommit.
@Test
public void commitTicketBranchMultiCommit() throws Exception {
setPatchsetAvailable(false);
TicketModel a = ticketService.createTicket(repo, newTicket("commitTicketBranchMultiCommit-A"));
TicketModel b = ticketService.createTicket(repo, newTicket("commitTicketBranchMultiCommit-B"));
String branchName = String.format("ticket/%d", a.number);
git.checkout().setCreateBranch(true).setName(branchName).call();
final String message1 = String.format("commit for #%d - patchset multi commit 1", b.number);
final RevCommit revCommit1 = makeCommit(message1);
final String commit1Sha = revCommit1.name();
final String message2 = String.format("commit for #%d - patchset multi commit 2", b.number);
final RevCommit revCommit2 = makeCommit(message2);
final String commit2Sha = revCommit2.name();
assertPushSuccess(commit2Sha, branchName);
a = ticketService.getTicket(repo, a.number);
b = ticketService.getTicket(repo, b.number);
assertFalse(a.hasReferences());
assertTrue(b.hasReferences());
List<Reference> cRefB = b.getReferences();
assertNotNull(cRefB);
assertEquals(2, cRefB.size());
assertNull(cRefB.get(0).ticketId);
assertEquals(commit1Sha, cRefB.get(1).hash);
assertEquals(commit2Sha, cRefB.get(0).hash);
}
use of com.gitblit.models.TicketModel in project gitblit by gitblit.
the class TicketReferenceTest method commitMasterAmendReference.
@Test
public void commitMasterAmendReference() throws Exception {
TicketModel a = ticketService.createTicket(repo, newTicket("commitMasterAmendReference-A"));
TicketModel b = ticketService.createTicket(repo, newTicket("commitMasterAmendReference-B"));
final String branchName = "master";
git.checkout().setCreateBranch(false).setName(branchName).call();
String message = String.format("commit before amend for #%d and #%d", a.number, b.number);
final RevCommit revCommit1 = makeCommit(message);
final String commit1Sha = revCommit1.name();
assertPushSuccess(commit1Sha, branchName);
a = ticketService.getTicket(repo, a.number);
b = ticketService.getTicket(repo, b.number);
assertTrue(a.hasReferences());
assertTrue(b.hasReferences());
List<Reference> cRefA = a.getReferences();
assertNotNull(cRefA);
assertEquals(1, cRefA.size());
assertNull(cRefA.get(0).ticketId);
assertEquals(commit1Sha, cRefA.get(0).hash);
List<Reference> cRefB = b.getReferences();
assertNotNull(cRefB);
assertEquals(1, cRefB.size());
assertNull(cRefB.get(0).ticketId);
assertEquals(commit1Sha, cRefB.get(0).hash);
//Confirm that old invalid references removed for both tickets
//and new reference added for one referenced ticket
message = String.format("commit after amend for #%d", a.number);
final String commit2Sha = amendCommit(message);
assertForcePushSuccess(commit2Sha, branchName);
a = ticketService.getTicket(repo, a.number);
b = ticketService.getTicket(repo, b.number);
assertTrue(a.hasReferences());
assertFalse(b.hasReferences());
cRefA = a.getReferences();
assertNotNull(cRefA);
assertEquals(1, cRefA.size());
assertNull(cRefA.get(0).ticketId);
assertEquals(commit2Sha, cRefA.get(0).hash);
}
use of com.gitblit.models.TicketModel in project gitblit by gitblit.
the class TicketServiceTest method testChangeComment.
@Test
public void testChangeComment() throws Exception {
// C1: create the ticket
Change c1 = newChange("testChangeComment() " + Long.toHexString(System.currentTimeMillis()));
TicketModel ticket = service.createTicket(getRepository(), c1);
assertTrue(ticket.number > 0);
assertTrue(ticket.changes.get(0).hasComment());
ticket = service.updateComment(ticket, c1.comment.id, "E1", "I changed the comment");
assertNotNull(ticket);
assertTrue(ticket.changes.get(0).hasComment());
assertEquals("I changed the comment", ticket.changes.get(0).comment.text);
assertTrue(service.deleteTicket(getRepository(), ticket.number, "D"));
}
Aggregations