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 getpatch/getdiff functions and remove unnecessary fallback #32817

Merged
merged 6 commits into from
Dec 24, 2024

Conversation

lunny
Copy link
Member

@lunny lunny commented Dec 12, 2024

Extract from #32786

git diff a..b is equal to git diff a b which is different from git diff a...b. For the pull request, we should always use git diff a...b.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Dec 12, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 12, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 12, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Dec 12, 2024
@lunny lunny added this to the 1.24.0 milestone Dec 17, 2024
@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 Dec 19, 2024
modules/git/repo_compare.go Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 23, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Dec 24, 2024
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

To be honest, I do not think the parseCompareArgs behavior is right.

It sometimes returns {"a..b"}, sometimes returns {"a", "b"}, does it really make sense? Why not make callers just pass "a...b" or "a..b"? And what's the use case for parsing a b (space separator)?

@lunny
Copy link
Member Author

lunny commented Dec 24, 2024

To be honest, I do not think the parseCompareArgs behavior is right.

It sometimes returns {"a..b"}, sometimes returns {"a", "b"}, does it really make sense? Why not make callers just pass "a...b" or "a..b"? And what's the use case for parsing a b (space separator)?

We can strictly parseCompareArgs only accept a...b and a..b and refuse a b if you think that's a problem. Although git supports both a..b and a b. I think it's just a habit or legacy reason.

services/pull/patch.go Outdated Show resolved Hide resolved
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 24, 2024

and refuse a b if you think that's a problem. Although git supports both a..b and a b. I think it's just a habit or legacy reason.

Yes, it is absolutely a problem. It is not a right habit or legacy reason. Git does NOT support git diff "a b". It only accepts git diff "a" "b" as separate arguments (aka "slice" in Golang), not in ONE string.

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 24, 2024
@wxiaoguang wxiaoguang changed the title Refactor getpatch/getdiff functions and remove fallback automatically Refactor getpatch/getdiff functions and remove unnecessary fallback Dec 24, 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 Dec 24, 2024
@lunny lunny merged commit b8b690f into go-gitea:main Dec 24, 2024
26 checks passed
@lunny lunny deleted the lunny/refactor_diff_funcs branch December 24, 2024 06:29
zjjhot added a commit to zjjhot/gitea that referenced this pull request Dec 25, 2024
* giteaofficial/main:
  demilestone should not include milestone (go-gitea#32923)
  fix textarea newline handle (go-gitea#32966)
  Fix Azure blob object `Seek`  (go-gitea#32974)
  Fix maven pom inheritance (go-gitea#32943)
  Refactor arch route handlers (go-gitea#32972)
  [skip ci] Updated translations via Crowdin
  Refactor tmpl and blob_excerpt (go-gitea#32967)
  Clarify path param naming (go-gitea#32969)
  Refactor getpatch/getdiff functions and remove unnecessary fallback (go-gitea#32817)
  Refactor request context (go-gitea#32956)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants