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: use git pull --tags instead of git fetch --tags #468

Merged
merged 2 commits into from
Mar 6, 2024
Merged

Conversation

russellwheatley
Copy link
Member

Description

Use git pull --tags instead of git fetch --tags. The problem with using fetch - the tag needs to be associated with a branch that is on remote. If it isn't (i.e. usually squashed and merge) it will not be retrieved and will remain orphaned on remote.

Using git pull --tags will pull all tags no matter the status of the branch.

Type of Change

  • feat -- New feature (non-breaking change which adds functionality)
  • 🛠️ fix -- Bug fix (non-breaking change which fixes an issue)
  • ! -- Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 refactor -- Code refactor
  • ci -- Build configuration change
  • 📝 docs -- Documentation
  • 🗑️ chore -- Chore

@Salakar Salakar requested a review from blaugold February 7, 2023 13:31
@blaugold
Copy link
Collaborator

blaugold commented Feb 7, 2023

I couldn't find anything on this difference between fetch and pull in the git docs. The docs for pull even say the following:

More precisely, git pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches.

Is this difference documented anywhere? I'd love to understand it better.

If we need to use git pull we probably need to be a bit more careful. Usually the current branch should be up to date with the remote before running melos version but users can make mistakes. I think we should require that if the current branch has a remote tracking branch it is up to date at the beginning of melos version and abort if it is not. Otherwise the behaviour is a bit unpredictable for users.

@Salakar
Copy link
Member

Salakar commented Feb 7, 2023

We've had cases on FlutterFire where git fetch --tags was run, but tags that are not attached to a ref weren't being pulled, and so older tags were being used to generate the changes; I'm not exactly sure why though, using pull seemed to do the trick at the time.

For context, I asked Russell to post this PR based on the FF release process; /~https://github.com/firebase/flutterfire/blob/master/CONTRIBUTING.md#run-a-release

Maybe this isn't the right solution for Melos, I'm not sure though

@Salakar Salakar removed the request for review from blaugold March 10, 2023 14:03
Copy link
Collaborator

@spydon spydon left a comment

Choose a reason for hiding this comment

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

Lgtm! I think this change seems sensible after reading up on git pull --tags vs git fetch --tags

@spydon spydon merged commit 109f5f9 into main Mar 6, 2024
10 checks passed
@spydon spydon deleted the use-git-pull branch March 6, 2024 10:14
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.

4 participants