diff options
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/gitblit/git/PatchsetCommand.java | 2 | ||||
-rw-r--r-- | src/main/java/com/gitblit/git/PatchsetReceivePack.java | 15 | ||||
-rw-r--r-- | src/main/java/com/gitblit/models/TicketModel.java | 1 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/com/gitblit/git/PatchsetCommand.java b/src/main/java/com/gitblit/git/PatchsetCommand.java index 21d2ac45..829ece1d 100644 --- a/src/main/java/com/gitblit/git/PatchsetCommand.java +++ b/src/main/java/com/gitblit/git/PatchsetCommand.java @@ -106,7 +106,7 @@ public class PatchsetCommand extends ReceiveCommand { public PatchsetCommand(String username, Patchset patchset) { super(patchset.isFF() ? ObjectId.fromString(patchset.parent) : ObjectId.zeroId(), - ObjectId.fromString(patchset.tip), null); + ObjectId.fromString(patchset.tip), getPatchsetBranch(patchset.ticketId, patchset.number)); this.change = new Change(username); this.change.patchset = patchset; } diff --git a/src/main/java/com/gitblit/git/PatchsetReceivePack.java b/src/main/java/com/gitblit/git/PatchsetReceivePack.java index 4a09139a..c44c95ef 100644 --- a/src/main/java/com/gitblit/git/PatchsetReceivePack.java +++ b/src/main/java/com/gitblit/git/PatchsetReceivePack.java @@ -774,6 +774,7 @@ public class PatchsetReceivePack extends GitblitReceivePack { // assign new id
long ticketId = ticketService.assignNewId(repository);
+ patchset.ticketId = ticketId;
// create the patchset command
psCmd = new PatchsetCommand(user.username, patchset);
@@ -1102,6 +1103,7 @@ public class PatchsetReceivePack extends GitblitReceivePack { newPatchset.tip = tip;
newPatchset.base = mergeBase;
newPatchset.commits = totalCommits;
+ newPatchset.ticketId = ticket == null ? 0 : ticket.number;
Patchset currPatchset = ticket == null ? null : ticket.getCurrentPatchset();
if (currPatchset == null) {
@@ -1196,12 +1198,10 @@ public class PatchsetReceivePack extends GitblitReceivePack { }
private RefUpdate updateRef(String ref, ObjectId newId, PatchsetType type) {
- ObjectId ticketRefId = ObjectId.zeroId();
+ ObjectId ticketRefId = null;
try {
ticketRefId = getRepository().resolve(ref);
- } catch (Exception e) {
- // ignore
- }
+ } catch (Exception ignored) {}
try {
RefUpdate ru = getRepository().updateRef(ref, false);
@@ -1217,7 +1217,7 @@ public class PatchsetReceivePack extends GitblitReceivePack { break;
}
- ru.setExpectedOldObjectId(ticketRefId);
+ ru.setExpectedOldObjectId((ticketRefId == null) ? ObjectId.zeroId() : ticketRefId);
ru.setNewObjectId(newId);
RefUpdate.Result result = ru.update(getRevWalk());
if (result == RefUpdate.Result.LOCK_FAILURE) {
@@ -1254,7 +1254,8 @@ public class PatchsetReceivePack extends GitblitReceivePack { ru.getResult(), ru.getName()));
return;
}
- ReceiveCommand cmd = new ReceiveCommand(ru.getOldObjectId(), ru.getNewObjectId(), ru.getName(), type);
+ ObjectId oldId = (ru.getOldObjectId() == null) ? ObjectId.zeroId() : ru.getOldObjectId();
+ ReceiveCommand cmd = new ReceiveCommand(oldId, ru.getNewObjectId(), ru.getName(), type);
RefLogUtils.updateRefLog(user, getRepository(), Arrays.asList(cmd));
}
@@ -1331,4 +1332,4 @@ public class PatchsetReceivePack extends GitblitReceivePack { public void sendAll() {
ticketNotifier.sendAll();
}
-} +}
diff --git a/src/main/java/com/gitblit/models/TicketModel.java b/src/main/java/com/gitblit/models/TicketModel.java index 65e29dc0..a60cdc44 100644 --- a/src/main/java/com/gitblit/models/TicketModel.java +++ b/src/main/java/com/gitblit/models/TicketModel.java @@ -1163,6 +1163,7 @@ public class TicketModel implements Serializable, Comparable<TicketModel> { private static final long serialVersionUID = 1L; + public long ticketId; public int number; public int rev; public String tip; |