-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GlobalBuildInfo plugin should search packed references for commit IDs #47464
GlobalBuildInfo plugin should search packed references for commit IDs #47464
Conversation
In recent versions of Git, references may be packed in a packed-refs file. If this happens, Gradle will need to look in that file to find build information.
Pinging @elastic/es-core-infra (:Core/Infra/Build) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of comments, otherwise LGTM. Thanks for catching this @williamrandolph.
buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java
Outdated
Show resolved
Hide resolved
revision = readFirstLine(refFile); | ||
} else { | ||
// Check packed references for commit ID | ||
Pattern p = Pattern.compile("^([a-f0-9]+) " + branchname + "$"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this even more strict since we know a sha1 hash is 40 characters with [a-f0-9]{40}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do we know what the entries that look like ^6d5d330548f66c1ba6d2913737ba93c5d5a39de9
mean? I couldn't find any documentation describing the actual format of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the last lines of my .git/packed-refs
file…
d7d5b3fbc408e3b4060d9df33dec9c43e29e9cbb refs/tags/v7.4.0
^22e1767283e61a198cb4db791ea66e3f11ab9910
It looks like we get that carrot notation when Elasticmachine tags a release. I'm not sure what the specific terminology is, but 22e17672
is the commit that's tagged for 7.4 and git show d7d5b3fbc
shows the tag. Perhaps the first line represents the "annotated tag object"? I wouldn't want to try to get any more definitive without finding the format documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious mostly. Seems we can safely ignore those entries.
buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java
Outdated
Show resolved
Hide resolved
The Files.readLines method needs to be used in a try-with-resources block. Also, we can be more specific in the regex, and what was the "branchname" variable should really be called "refName".
@elasticmachine Please run elasticsearch-ci/2 |
@williamrandolph I think this is in a state where it can be merged once the conflicts are resolved. Let's not let this branch get any more stale than it is. |
@elasticmachine please run elasticsearch-ci/packaging-sample-matrix |
@elasticmachine please run elasticsearch-ci/2 |
…elastic#47464) * GlobalBuildInfo plugin searches packed references In recent versions of Git, references may be packed in a packed-refs file. If this happens, Gradle will need to look in that file to find build information.
…elastic#47464) * GlobalBuildInfo plugin searches packed references In recent versions of Git, references may be packed in a packed-refs file. If this happens, Gradle will need to look in that file to find build information.
…elastic#47464) * GlobalBuildInfo plugin searches packed references In recent versions of Git, references may be packed in a packed-refs file. If this happens, Gradle will need to look in that file to find build information.
The packed-refs support was using the original .git path, changed to use the real .git directory after reference from worktree has been followed. Relates elastic#47464
The packed-refs support was using the original .git path, changed to use the real .git directory after reference from worktree has been followed. Relates #47464
The packed-refs support was using the original .git path, changed to use the real .git directory after reference from worktree has been followed. Relates #47464
The packed-refs support was using the original .git path, changed to use the real .git directory after reference from worktree has been followed. Relates #47464
The packed-refs support was using the original .git path, changed to use the real .git directory after reference from worktree has been followed. Relates elastic#47464
The packed-refs support was using the original .git path, changed to use the real .git directory after reference from worktree has been followed. Relates #47464
After a git garbage collection, I was unable to run
./gradlew
commands.My failures were as follows:
If you have version 2.23.0 of git, you should be able to reproduce after running:
Documentation on
git-pack-refs
is here: https://git-scm.com/docs/git-pack-refsThis code needs a couple of improvements (for example, there's no check for the existence of the packed-refs file), but I'm going ahead and posting the PR for discussion.