Skip to content

update: fix latest_tag in homebrew/brew update #8644

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

Merged
merged 3 commits into from
Sep 9, 2020
Merged

update: fix latest_tag in homebrew/brew update #8644

merged 3 commits into from
Sep 9, 2020

Conversation

shcai97
Copy link
Contributor

@shcai97 shcai97 commented Sep 8, 2020

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

brew update fetches commit history since latest_tag for Homebrew/brew. However, git ls-remote sorts the tag in lexicographical order by default. So the current command does not always get the latest tag.
For the moment,git ls-remote --tags --refs -q origin | tail -n1 | cut -f2 outputs refs/tags/2.4.9 instead of refs/tags/2.4.16. This commit provides a fix.

Sorry, something went wrong.

@shcai97
Copy link
Contributor Author

shcai97 commented Sep 8, 2020

I thought this piece of code is for updating brew in all situations.
After I read again, I found it only applies for those use a non-official source. (HOMEBREW_BREW_GIT_REMOTE set)
But I think this change still apply.

@maxim-belkin
Copy link
Contributor

maxim-belkin commented Sep 8, 2020

Thanks for the PR, @shcai97.
Indeed, git ls-remote --tags --refs -q origin returns refs in the lexicographical order. The --sort flag was added in Git 2.18, and the oldest version supported by Homebrew is 2.14.3 (see HOMEBREW_MINIMUM_GIT_VERSION in brew.sh file).
Homebrew had a similar situation in the past when it moved from using git tag ... --sort to git tag ... | sort ..., see d4311fd. So, until the minimum supported Git version is newer than or equal to 2.18, we have to use | sort approach. Can you update your PR to do that?

@shcai97
Copy link
Contributor Author

shcai97 commented Sep 8, 2020

Hi, Maxim. I think it should be good now.
One problem is that the fixed line only outputs the version number, so I add one more line to add refs/tags/ in front of the number to keep the same format.
I am not familiar with the --shallow-since. I have tested it on my machine, give version number only (2.4.16 instead of refs/tags/2.4.16) also works. I am not sure whether the additional line is necessary.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
@MikeMcQuaid MikeMcQuaid merged commit 959d2b7 into Homebrew:master Sep 9, 2020
@MikeMcQuaid
Copy link
Member

Thanks so much for your excellent first contribution! Without people like you submitting PRs we couldn't run this project. You rock, @shcai97!

@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 13, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants