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 ability to generate PR description from diff in a file or url #17

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

mkarle
Copy link
Contributor

@mkarle mkarle commented Sep 18, 2023

When integrating SKonsole into a GitHub Action, a problem arose when comparing changes from two different repositories. To get "git diff ..HEAD to work, the Action had to be in a specific state where the source branch had to be added as a downstream remote and then checked out. It was a headache, and I found that both Pull Request- and Issue comments-based actions have access to a diff url such as this one showing a README change.

This PR's diff is found here.
Result from dotnet run pr description --outputFormat json -d https://patch-diff.githubusercontent.com/raw/lemillermicrosoft/skonsole/pull/17.diff:

{
  "Title": "Add diff input file option to PRCommand",
  "Summary": "This pull request adds a new option to the PRCommand, allowing users to specify a diff input file or URL. This feature enhances the flexibility of the command by enabling users to provide custom diff content for generating pull request descriptions.",
  "Changes": [
    "Added a new option `--diffInputFile` (alias `-d`) to PRCommand, allowing users to specify a diff input file or URL",
    "Modified the `GeneratePRDescriptionCommand` method to include the new `diffInputFileOption`",
    "Updated the `RunPullRequestDescription` method to accept an additional parameter `diffInputFile`",
    "Implemented the `FetchDiff` method to handle fetching diff content from a file, URL, or git command based on the provided input"
  ]
}

If I copy to a file and run dotnet run pr description --outputFormat json -d "C:\Users\markkarle\Documents\testdiff.txt":

 {
  "Title": "Add diff input file option to PRCommand",
  "Summary": "This pull request adds a new option to the PRCommand, allowing users to specify a diff input file or URL. This makes it easier for users to generate pull request descriptions based on custom diff files or remote sources.",
  "Changes": [
    "Added a new option `--diffInputFile` (alias `-d`) to PRCommand, allowing users to specify a diff input file or URL",
    "Updated the `GeneratePRDescriptionCommand` method to include the new `diffInputFileOption`",
    "Modified the `RunPullRequestDescription` method to accept an additional `diffInputFile` parameter",
    "Implemented the `FetchDiff` method to handle fetching the diff content from a file, URL, or git command based on the provided `diffInputFile` value"
  ]
}

And finally if I leave out the option and run dotnet run pr description --outputFormat json

{
  "Title": "Add diff input file option to PRCommand",
  "Summary": "This pull request adds a new option to the PRCommand class, allowing users to specify a diff input file or URL. This new feature enhances the flexibility of the command and makes it more versatile for different use cases.",
  "Changes": [
    "Added a new option `--diffInputFile` (alias `-d`) to the PRCommand class, allowing users to specify a diff input file or URL.",
    "Updated the `GeneratePRDescriptionCommand` method to include the new `diffInputFileOption`.",
    "Modified the `RunPullRequestDescription` method to accept an additional parameter `diffInputFile` and use it when fetching the diff.",
    "Implemented the `FetchDiff` method to handle fetching the diff from a file, URL, or by running the `git show` command."
  ]
}

@lemillermicrosoft lemillermicrosoft merged commit d5620c4 into lemillermicrosoft:main Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants