瀏覽代碼

fix: Fix broken pushes to tickets

The update of JGit broke pushes to tickets. The ReceiveCommand now
requires all three arguments, oldId, newId and name, to be not null.
The ticket code handling pushes to tickets left name and old id as
null in certain cases. This is fixed by always providing values.
pull/1442/head
Florian Zschocke 1 年之前
父節點
當前提交
4baed92559

+ 1
- 1
src/main/java/com/gitblit/git/PatchsetCommand.java 查看文件



public PatchsetCommand(String username, Patchset patchset) { public PatchsetCommand(String username, Patchset patchset) {
super(patchset.isFF() ? ObjectId.fromString(patchset.parent) : ObjectId.zeroId(), 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 = new Change(username);
this.change.patchset = patchset; this.change.patchset = patchset;
} }

+ 8
- 7
src/main/java/com/gitblit/git/PatchsetReceivePack.java 查看文件

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

+ 1
- 0
src/main/java/com/gitblit/models/TicketModel.java 查看文件



private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;


public long ticketId;
public int number; public int number;
public int rev; public int rev;
public String tip; public String tip;

Loading…
取消
儲存