Browse Source

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 year ago
parent
commit
4baed92559

+ 1
- 1
src/main/java/com/gitblit/git/PatchsetCommand.java View File

@@ -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;
}

+ 8
- 7
src/main/java/com/gitblit/git/PatchsetReceivePack.java View File

@@ -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();
}
}
}

+ 1
- 0
src/main/java/com/gitblit/models/TicketModel.java View File

@@ -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;

Loading…
Cancel
Save