Repository navigation
fix: skip head merge commits on pull requests - #6253
Merged
Merged
Conversation
grouville
force-pushed
the
skip-merge-commit
branch
from
December 13, 2023 04:37
c58a9ec to
46b2c49
Compare
jedevc
reviewed
Dec 13, 2023
grouville
force-pushed
the
skip-merge-commit
branch
2 times, most recently
from
December 13, 2023 18:02
cee7515 to
0f3e3d8
Compare
marcosnils
reviewed
Dec 13, 2023
grouville
marked this pull request as draft
December 13, 2023 19:04
grouville
force-pushed
the
skip-merge-commit
branch
2 times, most recently
from
December 14, 2023 00:38
347404b to
2713137
Compare
grouville
marked this pull request as ready for review
December 14, 2023 05:29
Member
Author
|
@marcosnils the failing test does not seem to come from me. I re-ran it a few times when in draft, and I kept having the same issue, I wonder if it is a cache thing ? |
grouville
force-pushed
the
skip-merge-commit
branch
2 times, most recently
from
December 14, 2023 22:31
f927ea6 to
0005721
Compare
grouville
marked this pull request as draft
December 14, 2023 23:24
grouville
force-pushed
the
skip-merge-commit
branch
2 times, most recently
from
December 16, 2023 00:04
7cab516 to
4aabb0e
Compare
grouville
marked this pull request as ready for review
December 16, 2023 00:24
head merge commits on pull requests
jedevc
reviewed
Dec 18, 2023
When collecting labels on the engine in a VCS context, sometimes, the commit head is an appended commit (from that VCS) Signed-off-by: grouville <[email protected]>
…d HEAD state The TestLoadGitLabels test was updated to account for the `dagger.io/git.branch` label in the expected output for the "detached HEAD state" scenario. This change was necessary due to recent updates in the `LoadGitLabels` function in the `label.go` file. The function was modified to iterate over all references in the repository and check if any of them point to the commit hash. If a reference is found that matches the commit hash and it is a branch, the function adds the `dagger.io/git.branch` label. This new behavior allows the function to correctly identify the branch association of a commit, even in a detached HEAD state. The test was updated to reflect this change and now expects the `dagger.io/git.branch` label in the output for the "detached HEAD state" scenario. Signed-off-by: grouville <[email protected]>
Following Justin's comment, only escape merge commits in PR context Signed-off-by: grouville <[email protected]>
This commit implements a few changes: - After further checks, GitLab does not change the git history in a merge request context. It doesn't need to be handled - GitHub automatically creates a detached merge commit containing only the merge commit. To handle it, we need to fetch the origin branch and retrieve this commit. However, this requires authentication, which we bypass by leveraging the fact that GitHub Action automatically adds the GITHUB_TOKEN to any git commands inside their runner context Signed-off-by: grouville <[email protected]>
Signed-off-by: grouville <[email protected]>
Signed-off-by: grouville <[email protected]>
Aim is to have a very readable implementation that handles the two separate logics: - When the PR comes from a branch on the repo itself (origin) - When the PR comes from a branch on a fork. Here, GitHub does not give us enough information to find with certainty the remote. So we try to construct the remote from the env var information. If it does not work, continue with current implementation Signed-off-by: grouville <[email protected]>
In order to be as fast as possible, only fetch HEAD on either forked or origin remote Signed-off-by: grouville <[email protected]>
Remove tmate for debugging purposes Signed-off-by: grouville <[email protected]>
Signed-off-by: grouville <[email protected]>
grouville
force-pushed
the
skip-merge-commit
branch
from
December 18, 2023 20:38
4aabb0e to
2b6b55e
Compare
jedevc
approved these changes
Dec 19, 2023
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 https://linear.app/dagger/issue/DEV-3086/pull-user-commit-message-in-a-context-pr
When collecting labels on the engine in a VCS context, sometimes, the commit head is an appended commit (from that VCS) [PR / MR]. This fix skips the merge request commit when it is the head.
Repro/test: https://gist.github.com/grouville/6cf442d86c41c0746bbef1812160e7c0
12/13 Advancements
After reviews + some testing, a few changes have been implemented:
pull_requestsshall be be impactedGITHUB_TOKENsecrets to git CLI commands12/15 Advancements
Previous implementation was introducing a bug by printing errors to stdout, which polluted the
dagger listenconnection string.The error came from the fact that on Dagger, the PRs come from a fork and not the origin. However, after spending some time reverse engineering Github Actions' runner context, I did not find a 100% solution to retrieve the origin of a fork. This is a best try approach, where we build the fork's remote of a repo from available information. If we do not manage to do it, then we fallback on the current logic