Skip to content
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

git-checkout: Support branchless commits #181

Merged
merged 1 commit into from
Oct 12, 2024
Merged

git-checkout: Support branchless commits #181

merged 1 commit into from
Oct 12, 2024

Conversation

niwis
Copy link
Contributor

@niwis niwis commented Aug 27, 2024

When creating a database from a git repository, bender currently fetches all branches and tags from the remote before checking out the specified reference. However, it is possible that a commit does not belong to a branch or a tag. For instance, GitHub creates PR merge commits and stores their references in refs/pull. To checkout such a branchless commit, it must first be fetched explicitly.

Therefore, when creating the database, explicitly fetch the specified reference in addition to all branches and tags (those are still needed e.g. for bender update).

An open corner case is when Bender.lock is updated with a branchless commit hash after creating the database, but the manifest is not. This will skip fetching altogether and the database might not contain the desired branchless commit. A possible solution would be to track the modification time of Bender.lock; see manifest_mtime. However, since this is not the intended use of bender and, in a similar form, already possible today, I chose not to address this for now.

Context: The pulp-action integrate currently does not work for pull_request events, since the run's context (the PR merge commit) is not accessible by the dependent's CI due to the issue addressed by this PR. (see https://github.com/pulp-platform/cva6/actions/runs/10512893871/job/29127223222)

@niwis niwis requested a review from micprog August 27, 2024 18:06
When creating a database from a git repository, bender currently fetches
all branches and tags from the remote before checking out the specified
reference. However, it is possible that a commit does not belong to a
branch or a tag. For instance, GitHub creates PR merge commits and
stores their references in `refs/pull`. To checkout such a branchless
commit, it must first be fetched explicitly.

Therefore, when creating the database, explicitly fetch the specified
reference in addition to all branches and tags (those are still needed
e.g. for `bender update`).

An open corner case is when `Bender.lock` is updated with a branchless
commit hash after creating the database, but the manifest is not. This
will skip fetching altogether and the database might not contain the
desired branchless commit. A possible solution would be to track the
modification time of `Bender.lock`; see `manifest_mtime`. However, since
this is not the intended use of bender and, in a similar form, already
possible today, I chose not to address this for now.

Context: The pulp-action
[integrate](https://github.com/pulp-platform/pulp-actions/tree/main/integrate)
currently does not work for `pull_request` events, since the run's
context (the PR merge commit) is not accessible by the dependent's CI
due to the issue addressed by this PR. (see
https://github.com/pulp-platform/cva6/actions/runs/10512893871/job/29127223222)

Signed-off-by: Nils Wistoff <nwistoff@iis.ee.ethz.ch>
Copy link
Member

@micprog micprog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@micprog micprog merged commit 306a7a0 into master Oct 12, 2024
6 checks passed
@micprog micprog deleted the nw/fetch-ref branch October 12, 2024 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants