-
Notifications
You must be signed in to change notification settings - Fork 1
Test commit for the test branch #2
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
Open
evmorov
wants to merge
7
commits into
main
Choose a base branch
from
test-branch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e4f4d5
Test commit for the test branch
evmorov 0d49878
Merge branch 'main' into test-branch
evmorov 5f0f869
More changes
evmorov 2cb20b5
Another change
evmorov f19f673
Add binary
evmorov f209350
Other changes
evmorov 54ca378
Add svg
evmorov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| example_id | status | run_time | | ||
| ------------------------------ | ------ | --------------- | | ||
| ./spec/prreview_spec.rb[1:1] | passed | 0.00059 seconds | | ||
| ./spec/prreview_spec.rb[2:1:1] | passed | 0.01083 seconds | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +0,0 @@ | ||
| ``` | ||
| ruby pr-review.rb https://github.com/evmorov/pr-review-prompt/pull/2 | ||
| ``` | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,85 +5,4 @@ def initialize | |
| @pr_url = ARGV[0] | ||
| raise "No Github URL is provided" if @pr_url.nil? || @pr_url.empty? | ||
| end | ||
|
|
||
| def run | ||
| prompt = [] | ||
|
|
||
| prompt << @pr_url | ||
|
|
||
| readme = request_gh("gh repo view #{repo_url}") | ||
| prompt << wrap_content('README.md', remove_markdown(readme)) | ||
|
|
||
| details_with_comments = request_gh("gh pr view --comments #{@pr_url}") | ||
| prompt << wrap_content('PR description and comments', remove_markdown(details_with_comments)) | ||
|
|
||
| commits = request_gh(%{gh pr view --json commits #{@pr_url} | jq -r '.commits[] | "\\(.authors[0].name) (\\(.authors[0].login)) – \\(.messageHeadline)"'}) | ||
| prompt << wrap_content('PR commits', commits) | ||
|
|
||
| prompt << files | ||
|
|
||
| diff = request_gh("gh pr diff #{@pr_url}") | ||
| prompt << wrap_content('PR diff', diff) | ||
|
|
||
| task = "Check the PR. Do you see any problems there?" | ||
| prompt << wrap_content('Your task', task) | ||
|
|
||
| IO.popen('pbcopy', 'w') { |io| io.puts(prompt) } | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def files | ||
| result = [] | ||
| file_paths = request_gh("gh pr diff --name-only #{@pr_url}") | ||
|
|
||
| file_paths.split("\n").each do |file_path| | ||
| content = request_gh("gh api #{api_contents_path}/#{file_path}?ref=#{branch} | jq -r '.content' | base64 --decode") | ||
| next unless content | ||
|
|
||
| result << wrap_content(file_path, content) | ||
| end | ||
|
|
||
| result | ||
| end | ||
|
|
||
| def api_contents_path | ||
| @api_contents_path ||= "repos/#{repo_url.split('github.com/')[1]}/contents" | ||
| end | ||
|
|
||
| def repo_url | ||
| @repo_url ||= @pr_url.split('/pull')[0] | ||
| end | ||
|
|
||
| def branch | ||
| @branch ||= request_gh("gh pr view #{@pr_url} --json headRefName -q .headRefName").strip | ||
| end | ||
|
Comment on lines
-58
to
-60
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not resolved with a link evmorov/lang-compare#1 |
||
|
|
||
| def wrap_content(file_name, content) | ||
| r = [] | ||
| r << "\n" | ||
| r << "## #{file_name}" | ||
| r << "\n" | ||
| r << "```" | ||
| r << content | ||
| r << "```" | ||
| end | ||
|
|
||
| def request_gh(cmd) | ||
| puts cmd | ||
| stdout, stderr, status = Open3.capture3(cmd) | ||
|
|
||
| unless stderr.empty? | ||
| puts stderr | ||
| return | ||
| end | ||
|
|
||
| stdout | ||
| end | ||
|
|
||
| def remove_markdown(content) | ||
| content.delete("`").delete("#") | ||
| end | ||
| end | ||
|
|
||
| PrReview.new.run | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.