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

Refactor git version functions and check compatibility #29155

Merged
merged 3 commits into from
Feb 14, 2024

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Feb 13, 2024

Introduce a new function checkGitVersionCompatibility, when the git version can't be used by Gitea, tell the end users to downgrade or upgrade. The refactored functions are related to make the code easier to test.

And simplify the comments for "safe.directory"

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 13, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 13, 2024
@wxiaoguang wxiaoguang added type/enhancement An improvement of existing functionality backport/v1.21 This PR should be backported to Gitea 1.21 labels Feb 13, 2024
@wxiaoguang wxiaoguang added this to the 1.22.0 milestone Feb 13, 2024
modules/git/git.go Outdated Show resolved Hide resolved
return gitVersion, err
// version string is like: "git version 2.29.3" or "git version 2.29.3.windows.1"
versionString := fields[2]
if pos := strings.Index(versionString, "windows"); pos >= 1 {
Copy link
Member

Choose a reason for hiding this comment

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

>= 1? Not >= 0?

Copy link
Contributor Author

@wxiaoguang wxiaoguang Feb 13, 2024

Choose a reason for hiding this comment

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

>= 1, because there is versionString[:pos-1] below.

Copy link
Member

Choose a reason for hiding this comment

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

But we could use >= 0 and :pos.

Copy link
Contributor Author

@wxiaoguang wxiaoguang Feb 13, 2024

Choose a reason for hiding this comment

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

That's from old code. I guess it might want to work with 2.3.4.windows and 2.3.4-windows

image

Copy link
Member

Choose a reason for hiding this comment

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

Right, the -1 is needed for the prefix and therefore i must be >=1.

@wxiaoguang wxiaoguang added backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! labels Feb 13, 2024
Copy link
Member

@silverwind silverwind left a comment

Choose a reason for hiding this comment

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

This seems rather time-critical to get out.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 13, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 14, 2024
@wxiaoguang wxiaoguang enabled auto-merge (squash) February 14, 2024 16:53
@wxiaoguang wxiaoguang added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 14, 2024
@wxiaoguang
Copy link
Contributor Author

Thank you for reviewing and approving. The backport is done manually : #29157

There is a slight difference in the backport, to try the best to avoid breaking a stable release: bypass the GIT_FLUSH bug there.

Feel free to edit the PR directly if you feel that it shouldn't be done.

@wxiaoguang wxiaoguang merged commit d0183df into go-gitea:main Feb 14, 2024
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 14, 2024
@wxiaoguang wxiaoguang deleted the improve-git-version branch February 14, 2024 21:17
silverwind pushed a commit to silverwind/gitea that referenced this pull request Feb 15, 2024
Introduce a new function checkGitVersionCompatibility, when the git
version can't be used by Gitea, tell the end users to downgrade or
upgrade. The refactored functions are related to make the code easier to
test.

And simplify the comments for "safe.directory"

---------

Co-authored-by: delvh <[email protected]>
wxiaoguang added a commit that referenced this pull request Feb 17, 2024
Backport #29155 with an extra change: tolerate the git 2.43.1 GIT_FLUSH
bug in Gitea 1.21.x, more details in the comment of repo_attribute.go

Manually tested with git 2.43.1 and an old git (2.39.2)
silverwind pushed a commit to silverwind/gitea that referenced this pull request Feb 20, 2024
Introduce a new function checkGitVersionCompatibility, when the git
version can't be used by Gitea, tell the end users to downgrade or
upgrade. The refactored functions are related to make the code easier to
test.

And simplify the comments for "safe.directory"

---------

Co-authored-by: delvh <[email protected]>
Copy link

Automatically locked because of our CONTRIBUTING guidelines

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants