Repository navigation
fix: ensure we get correct data for prs - #7111
Merged
Merged
Conversation
jedevc
marked this pull request as draft
April 17, 2024 15:20
jedevc
force-pushed
the
fix-telemetry-git-merge-data
branch
7 times, most recently
from
April 17, 2024 16:24
741c34c to
6dbb8a7
Compare
jedevc
marked this pull request as ready for review
April 17, 2024 16:24
Contributor
Author
|
cc @grouville who wrote the original implementation of this in #6253. |
vito
approved these changes
Apr 17, 2024
Contributor
There was a problem hiding this comment.
Would this work?:
Suggested change
| cmd = exec.Command("git", "rev-parse", "FETCH_HEAD") | |
| cmd = exec.Command("git", "rev-parse", target) |
Since this runs on the host, just trying to avoid any funny business with parallel fetches.
Contributor
Author
There was a problem hiding this comment.
Aha, discovered that we can get this info out much more easily using --porcelain: https://git-scm.com/docs/git-fetch#_output.
Then we don't need to worry about the timing/etc of this.
Member
|
Impressed, how did you find out this trick ? 🤯 I love it 👏 |
Instead of messing around with a bunch of remotes, etc, we can apply this simple little trick. `GITHUB_REF` contains the "the fully-formed ref of the branch or tag that triggered the workflow run" (see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context). Now, if the ref starts with "refs/pull/", it's a pull request. These usually end in "/merge", to indicate that this is the result of merging with the base branch. However, we can just swap this "/merge" for a "/head" to get the actual head - then we can grab all the interesting commit details from there. What's really cool is that these should just all be available on the "origin" - GitHub automagically populates them for us. Signed-off-by: Justin Chadwell <[email protected]>
jedevc
force-pushed
the
fix-telemetry-git-merge-data
branch
from
April 18, 2024 12:54
6dbb8a7 to
71bd229
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6452.
Instead of messing around with a bunch of remotes, etc, we can apply this simple little trick.
GITHUB_REFcontains the "the fully-formed ref of the branch or tag that triggered the workflow run" (see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context).Now, if the ref starts with "refs/pull/", it's a pull request. These usually end in "/merge", to indicate that this is the result of merging with the base branch. However, we can just swap this "/merge" for a "/head" to get the actual head - then we can grab all the interesting commit details from there.
What's really cool is that these should just all be available on the "origin" - GitHub automagically populates them for us.