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

Add go wrapper around git diff-tree --raw -r -M #33369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

McRaeAlex
Copy link

  • Implemented calling git diff-tree
  • Ensures wrapper function is called with valid arguments
  • Parses output into go struct, using strong typing when possible

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 23, 2025
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 23, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Jan 23, 2025
@McRaeAlex McRaeAlex marked this pull request as draft January 23, 2025 20:31
@McRaeAlex McRaeAlex marked this pull request as ready for review January 23, 2025 20:32
@McRaeAlex
Copy link
Author

Context for this PR: This was split out of a larger PR I hope to upstream to gitea for showing all files in a file tree at once rather than having a show more button at the bottom.

Screenshot 2025-01-23 at 12 36 39 PM

Note that this wouldn't change the behaviour of the files list to the right of the file tree. (Lets have that discussion in the PR which modifies the frontend)

 * Implemented calling git diff-tree
 * Ensures wrapper function is called with valid arguments
 * Parses output into go struct, using strong typing when possible
return nil, err
}

cmd := git.NewCommand(ctx, "diff-tree", "--raw", "-r", "--find-renames").AddDynamicArguments(baseCommitID, headCommitID)
Copy link
Member

Choose a reason for hiding this comment

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

For pull request files changed page, it needs baseCommitID...headCommitID. I think it's better to have another parameter to let outside functions decide it.

return baseCommit.ID.String(), headCommit.ID.String(), nil
}

func parseGitDiffTree(output string) ([]*DiffTreeRecord, error) {
Copy link
Member

Choose a reason for hiding this comment

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

How about to use rd io.Reader as the parameter?

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 size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants