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;
}
\r
// assign new id\r
long ticketId = ticketService.assignNewId(repository);\r
+ patchset.ticketId = ticketId;\r
\r
// create the patchset command\r
psCmd = new PatchsetCommand(user.username, patchset);\r
newPatchset.tip = tip;\r
newPatchset.base = mergeBase;\r
newPatchset.commits = totalCommits;\r
+ newPatchset.ticketId = ticket == null ? 0 : ticket.number;\r
\r
Patchset currPatchset = ticket == null ? null : ticket.getCurrentPatchset();\r
if (currPatchset == null) {\r
}\r
\r
private RefUpdate updateRef(String ref, ObjectId newId, PatchsetType type) {\r
- ObjectId ticketRefId = ObjectId.zeroId();\r
+ ObjectId ticketRefId = null;\r
try {\r
ticketRefId = getRepository().resolve(ref);\r
- } catch (Exception e) {\r
- // ignore\r
- }\r
+ } catch (Exception ignored) {}\r
\r
try {\r
RefUpdate ru = getRepository().updateRef(ref, false);\r
break;\r
}\r
\r
- ru.setExpectedOldObjectId(ticketRefId);\r
+ ru.setExpectedOldObjectId((ticketRefId == null) ? ObjectId.zeroId() : ticketRefId);\r
ru.setNewObjectId(newId);\r
RefUpdate.Result result = ru.update(getRevWalk());\r
if (result == RefUpdate.Result.LOCK_FAILURE) {\r
ru.getResult(), ru.getName()));\r
return;\r
}\r
- ReceiveCommand cmd = new ReceiveCommand(ru.getOldObjectId(), ru.getNewObjectId(), ru.getName(), type);\r
+ ObjectId oldId = (ru.getOldObjectId() == null) ? ObjectId.zeroId() : ru.getOldObjectId();\r
+ ReceiveCommand cmd = new ReceiveCommand(oldId, ru.getNewObjectId(), ru.getName(), type);\r
RefLogUtils.updateRefLog(user, getRepository(), Arrays.asList(cmd));\r
}\r
\r
public void sendAll() {\r
ticketNotifier.sendAll();\r
}\r
-}
+}\r