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

Fix git ref to allow branches and tags #3095

Merged
merged 7 commits into from
Jul 23, 2024
Merged

Fix git ref to allow branches and tags #3095

merged 7 commits into from
Jul 23, 2024

Conversation

emcfarlane
Copy link
Contributor

@emcfarlane emcfarlane commented Jun 18, 2024

This changes the git ref input to align with the git notion of a ref as a tag or branch. We now always try to fetch a given ref before falling back to fetching the HEAD to resolve partial refs. If both a ref and branch are provided, the branch is fetched directly before resolving the ref. The inputs tag and commit can still be used but can now be replaced by setting the ref.

For example:

  • Branch ref=main will fetch and checkout the main branch
  • Tag ref=v1.0.0 will fetch and checkout the v1.0.0 tag
  • Partial ref=123456 will fetch HEAD and checkout 123456
  • Branch with partial ref=123456,branch=feature will fetch feature and checkout 123456
  • Commit ref=<sha> will fetch <sha> and checkout <sha>
  • Branch with commit ref=<sha>,branch=feature with fetch feature and checkout <sha>

Fixes #2932

This changes the git ref input to align with the git notion of a ref as
a tag or branch. We now always try to fetch a given ref before falling
back to fetching the HEAD to resolve partial refs. If both a ref and
branch are provided, the branch is fetched directly before resolving the
ref.

For example:
 - Branch ref=main will fetch and checkout the main branch
 - Tag ref=tag will fetch and checkout the tag
 - Partial ref=123456 will fetch HEAD and checkout 123456
 - Branch with partial ref=123456,branch=feature will fetch feature and
   checkout 123456
private/pkg/git/cloner.go Show resolved Hide resolved
private/pkg/git/cloner.go Show resolved Hide resolved
private/pkg/git/cloner.go Show resolved Hide resolved
Copy link
Member

@bufdev bufdev left a comment

Choose a reason for hiding this comment

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

I am very out of date on this package, so assume I approve, and get a review from someone else more familiar with git.

@doriable
Copy link
Member

We cannot currently merge this since it breaks the behaviour for #419 -- we'll need to investigate a solution that continues to work with that.

Copy link
Contributor

github-actions bot commented Jul 22, 2024

The latest Buf updates on your PR.

BuildFormatLintBreakingRunUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedviewJul 23, 2024, 5:33 PM

@emcfarlane emcfarlane marked this pull request as ready for review July 22, 2024 13:09
@marcus-griep-simplisafe
Copy link

marcus-griep-simplisafe commented Aug 26, 2024

Related to #3265. Do we have an alternate formulation that will work for the suggestion in #419?

@emcfarlane
Copy link
Contributor Author

@marcus-griep-simplisafe updated in the other issue. Working on a fix.

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.

Git inputs cannot reference tags with the ref option
4 participants