Resolved branch revision in Source Extension Point (#1803)

This adds the "resolved revision" of the HEAD (of the current branch, if branches are supported) to the extension point repos.sources.extensions. This "resolved revision" holds the current HEAD revision of the repository (or the selected branch, if branches are supported). This means you can check, whether the release has changed since an extension has been rendered for the first time.

Co-authored-by: Konstantin Schaper <konstantin.schaper@cloudogu.com>
This commit is contained in:
René Pfeuffer
2021-10-20 13:29:47 +02:00
committed by GitHub
parent d41b293109
commit 27b9d2c78a
14 changed files with 217 additions and 32 deletions

View File

@@ -278,8 +278,8 @@ class AbstractGitCommand {
logger.debug("pushed changes");
}
Ref getCurrentRevision() throws IOException {
return getClone().getRepository().getRefDatabase().findRef("HEAD");
ObjectId getCurrentObjectId() throws IOException {
return getClone().getRepository().getRefDatabase().findRef("HEAD").getObjectId();
}
private Person determineAuthor(Person author) {

View File

@@ -92,7 +92,7 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
boolean initialCommit = getClone().getRepository().getRefDatabase().getRefs().isEmpty();
if (!StringUtils.isEmpty(request.getExpectedRevision())
&& !request.getExpectedRevision().equals(getCurrentRevision().getName())) {
&& !request.getExpectedRevision().equals(getCurrentObjectId().getName())) {
throw new ConcurrentModificationException(ContextEntry.ContextBuilder.entity("Branch", request.getBranch() == null ? "default" : request.getBranch()).in(repository).build());
}
for (ModifyCommandRequest.PartialRequest r : request.getRequests()) {