Search in sources :

Example 1 with Reference

use of com.gitblit.models.TicketModel.Reference in project gitblit by gitblit.

the class TicketReferenceTest method commitTicketBranchDeleteNoMergeReference.

@Test
public void commitTicketBranchDeleteNoMergeReference() throws Exception {
    setPatchsetAvailable(false);
    TicketModel a = ticketService.createTicket(repo, newTicket("commitTicketBranchDeleteNoMergeReference-A"));
    TicketModel b = ticketService.createTicket(repo, newTicket("commitTicketBranchDeleteNoMergeReference-B"));
    TicketModel c = ticketService.createTicket(repo, newTicket("commitTicketBranchDeleteNoMergeReference-C"));
    assertFalse(c.hasPatchsets());
    String branchName = String.format("ticket/%d", c.number);
    git.checkout().setCreateBranch(true).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);
    c = ticketService.getTicket(repo, c.number);
    assertTrue(a.hasReferences());
    assertTrue(b.hasReferences());
    assertFalse(c.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
    assertDeleteBranch(branchName);
    a = ticketService.getTicket(repo, a.number);
    b = ticketService.getTicket(repo, b.number);
    c = ticketService.getTicket(repo, c.number);
    assertFalse(a.hasReferences());
    assertFalse(b.hasReferences());
    assertFalse(c.hasReferences());
}
Also used : Reference(com.gitblit.models.TicketModel.Reference) TicketModel(com.gitblit.models.TicketModel) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 2 with Reference

use of com.gitblit.models.TicketModel.Reference in project gitblit by gitblit.

the class TicketReferenceTest method commentSingleReference.

@Test
public void commentSingleReference() throws Exception {
    TicketModel a = ticketService.createTicket(repo, newTicket("commentSingleReference-A"));
    TicketModel b = ticketService.createTicket(repo, newTicket("commentSingleReference-B"));
    final Change comment = newComment(String.format("comment for #%d - single reference", b.number));
    assertNotNull(ticketService.updateTicket(repo, a.number, comment));
    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(1, cRefB.size());
    assertEquals(a.number, cRefB.get(0).ticketId.longValue());
    assertEquals(comment.comment.id, cRefB.get(0).hash);
}
Also used : Reference(com.gitblit.models.TicketModel.Reference) TicketModel(com.gitblit.models.TicketModel) Change(com.gitblit.models.TicketModel.Change) Test(org.junit.Test)

Example 3 with Reference

use of com.gitblit.models.TicketModel.Reference in project gitblit by gitblit.

the class TicketReferenceTest method commitTicketBranchSingleReference.

@Test
public void commitTicketBranchSingleReference() throws Exception {
    setPatchsetAvailable(false);
    TicketModel a = ticketService.createTicket(repo, newTicket("commitTicketBranchSingleReference-A"));
    TicketModel b = ticketService.createTicket(repo, newTicket("commitTicketBranchSingleReference-B"));
    String branchName = String.format("ticket/%d", a.number);
    git.checkout().setCreateBranch(true).setName(branchName).call();
    final String message = String.format("commit for #%d - patchset single reference", 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);
    assertFalse(a.hasReferences());
    assertTrue(b.hasReferences());
    List<Reference> cRefB = b.getReferences();
    assertNotNull(cRefB);
    assertEquals(1, cRefB.size());
    assertNull(cRefB.get(0).ticketId);
    assertEquals(commit1Sha, cRefB.get(0).hash);
}
Also used : Reference(com.gitblit.models.TicketModel.Reference) TicketModel(com.gitblit.models.TicketModel) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 4 with Reference

use of com.gitblit.models.TicketModel.Reference in project gitblit by gitblit.

the class TicketReferenceTest method commitMasterSingleReference.

@Test
public void commitMasterSingleReference() throws Exception {
    TicketModel a = ticketService.createTicket(repo, newTicket("commitMasterSingleReference-A"));
    final String branchName = "master";
    git.checkout().setCreateBranch(false).setName(branchName).call();
    final String message = String.format("commit for #%d - single 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);
}
Also used : Reference(com.gitblit.models.TicketModel.Reference) TicketModel(com.gitblit.models.TicketModel) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 5 with Reference

use of com.gitblit.models.TicketModel.Reference in project gitblit by gitblit.

the class TicketReferenceTest method commentMultiReference.

@Test
public void commentMultiReference() throws Exception {
    TicketModel a = ticketService.createTicket(repo, newTicket("commentMultiReference-A"));
    TicketModel b = ticketService.createTicket(repo, newTicket("commentMultiReference-B"));
    TicketModel c = ticketService.createTicket(repo, newTicket("commentMultiReference-C"));
    final Change comment = newComment(String.format("comment for #%d and #%d - multi reference", b.number, c.number));
    assertNotNull(ticketService.updateTicket(repo, a.number, comment));
    a = ticketService.getTicket(repo, a.number);
    b = ticketService.getTicket(repo, b.number);
    c = ticketService.getTicket(repo, c.number);
    assertFalse(a.hasReferences());
    assertTrue(b.hasReferences());
    assertTrue(c.hasReferences());
    List<Reference> cRefB = b.getReferences();
    assertNotNull(cRefB);
    assertEquals(1, cRefB.size());
    assertEquals(a.number, cRefB.get(0).ticketId.longValue());
    assertEquals(comment.comment.id, cRefB.get(0).hash);
    List<Reference> cRefC = c.getReferences();
    assertNotNull(cRefC);
    assertEquals(1, cRefC.size());
    assertEquals(a.number, cRefC.get(0).ticketId.longValue());
    assertEquals(comment.comment.id, cRefC.get(0).hash);
}
Also used : Reference(com.gitblit.models.TicketModel.Reference) TicketModel(com.gitblit.models.TicketModel) Change(com.gitblit.models.TicketModel.Change) Test(org.junit.Test)

Aggregations

TicketModel (com.gitblit.models.TicketModel)16 Reference (com.gitblit.models.TicketModel.Reference)16 Test (org.junit.Test)16 RevCommit (org.eclipse.jgit.revwalk.RevCommit)13 Change (com.gitblit.models.TicketModel.Change)3 MergeResult (org.eclipse.jgit.api.MergeResult)1 PushResult (org.eclipse.jgit.transport.PushResult)1 RemoteRefUpdate (org.eclipse.jgit.transport.RemoteRefUpdate)1