8000 Add .diff and .patch support to compare by badhezi · Pull Request #34433 · go-gitea/gitea · GitHub
[go: up one dir, main page]

Skip to content

Add .diff and .patch support to compare #34433

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

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

badhezi
Copy link
Contributor
@badhezi badhezi commented May 12, 2025

Implements proposal #34410
Screenshot 2025-05-12 at 17 25 44
Screenshot 2025-05-12 at 17 25 37

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 12, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code and removed modifies/api This PR adds API routes or modifies them labels May 12, 2025
@wxiaoguang
Copy link
Contributor

Some things in my mind:

  1. It needs some tests to cover the behavior, otherwise this feature would get broken in the future.
  2. It needs to handle edge cases like the.branch.name.contains.diff, the logic should be like this:
    • Parse {ref1}...{ref2}
    • If ref2 exists, then do not trim any suffix
    • If ref2 doesn't exist and it ends with .diff or .patch, then respond the diff/patch
  3. Maybe it could add some dropdown menu items on the UI to make users could download the diff/patch by some clicks

@wxiaoguang wxiaoguang added this to the 1.25.0 milestone May 13, 2025
@wxiaoguang wxiaoguang marked this pull request as draft May 13, 2025 01:24
@badhezi badhezi force-pushed the dev/hezi/add-raw-diff-patch branch from 3acbb9f to bc79694 Compare May 13, 2025 19:56
@github-actions github-actions bot added the modifies/templates This PR modifies the template files label May 14, 2025
@@ -73,3 +73,14 @@ func (repo *Repository) GetTreePathLatestCommit(refName, treePath string) (*Comm
}
return repo.GetCommit(strings.TrimSpace(stdout))
}

// RevParse resolves a revision reference to other git-related objects
func (repo *Repository) RevParse(ref, file string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is it really used except the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks ill either move it to test files or find a workaround

Comment on lines +243 to +244
ref2IsBranch := gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, infos[1])
ref2IsTag := gitrepo.IsTagExist(ctx, ctx.Repo.Repository, infos[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

The path format is like this:

What if the path is {:baseBranch}...{:headOwner}/{:headRepoName}:{:headBranch}.patch?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks ill address that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0