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
Merge pull request just by number #186
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -363,28 +363,43 @@ def checkout(args) | |
end | ||
|
||
# $ git merge https://github.com/defunkt/hub/pull/73 | ||
# or | ||
# $ git merge PR173 | ||
# $ git merge pr173 | ||
# $ git merge pull173 | ||
# $ git merge pull/173 | ||
# > git fetch git://github.com/mislav/hub.git +refs/heads/feature:refs/remotes/mislav/feature | ||
# > git merge mislav/feature --no-ff -m 'Merge pull request #73 from mislav/feature...' | ||
def merge(args) | ||
_, url_arg = args.words | ||
if url = resolve_github_url(url_arg) and url.project_path =~ /^pull\/(\d+)/ | ||
pull_id = nil | ||
project_url = nil | ||
if url_arg =~ /(pr|pull)(-|\/)?(\d+)/i | ||
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. we could also match on number only by adding |
||
pull_id = $3 | ||
url = resolve_github_url(local_repo.main_project.web_url) | ||
elsif url = resolve_github_url(url_arg) and url.project_path =~ /^pull\/(\d+)/ | ||
pull_id = $1 | ||
pull_data = api_client.pullrequest_info(url.project, pull_id) | ||
else | ||
abort "Error : don't understand what #{url_arg} mean" | ||
end | ||
|
||
user, branch = pull_data['head']['label'].split(':', 2) | ||
abort "Error: #{user}'s fork is not available anymore" unless pull_data['head']['repo'] | ||
project_url = url.project | ||
pull_data = api_client.pullrequest_info(project_url, pull_id) | ||
|
||
url = github_project(url.project_name, user).git_url(:private => pull_data['head']['repo']['private'], | ||
:https => https_protocol?) | ||
user, branch = pull_data['head']['label'].split(':', 2) | ||
abort "Error: #{user}'s fork is not available anymore" unless pull_data['head']['repo'] | ||
|
||
merge_head = "#{user}/#{branch}" | ||
args.before ['fetch', url, "+refs/heads/#{branch}:refs/remotes/#{merge_head}"] | ||
url = github_project(url.project_name, user).git_url(:private => pull_data['head']['repo']['private'], | ||
:https => https_protocol?) | ||
|
||
merge_head = "#{user}/#{branch}" | ||
args.before ['fetch', url, "+refs/heads/#{branch}:refs/remotes/#{merge_head}"] | ||
|
||
idx = args.index url_arg | ||
args.delete_at idx | ||
args.insert idx, merge_head, '--no-ff', '-m', | ||
"Merge pull request ##{pull_id} from #{merge_head}\n\n#{pull_data['title']}" | ||
|
||
idx = args.index url_arg | ||
args.delete_at idx | ||
args.insert idx, merge_head, '--no-ff', '-m', | ||
"Merge pull request ##{pull_id} from #{merge_head}\n\n#{pull_data['title']}" | ||
end | ||
end | ||
|
||
# $ git cherry-pick http://github.com/mislav/hub/commit/a319d88#comments | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the rest of the diff is only dedent, and remove of the final end.