-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
charlierudolph
committed
Dec 2, 2014
1 parent
9d0a532
commit 40d22eb
Showing
17 changed files
with
177 additions
and
7 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#### NAME | ||
|
||
git-pr - create a new pull request | ||
|
||
|
||
#### SYNOPSIS | ||
|
||
``` | ||
git pr | ||
``` | ||
|
||
|
||
#### DESCRIPTION | ||
|
||
Opens a browser to a new pull request for the current branch. | ||
Supported only for repositories hosted on Github and Bitbucket. |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Feature: git-pr when origin is on Bitbucket over HTTPS | ||
|
||
Background: | ||
Given I have a feature branch named "feature" | ||
And my remote origin is on Bitbucket through HTTPS | ||
And I am on the "feature" branch | ||
When I run `git pr` | ||
|
||
|
||
Scenario: | ||
Then I see a browser window for a new pull request on Bitbucket for the "feature" branch |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Feature: git-pr when origin is on Bitbucket over SSH | ||
|
||
Background: | ||
Given I have a feature branch named "feature" | ||
And my remote origin is on Bitbucket through SSH | ||
And I am on the "feature" branch | ||
When I run `git pr` | ||
|
||
|
||
Scenario: | ||
Then I see a browser window for a new pull request on Bitbucket for the "feature" branch |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Feature: git-pr when origin is on Github over HTTPS | ||
|
||
Background: | ||
Given I have a feature branch named "feature" | ||
And my remote origin is on Github through HTTPS | ||
And I am on the "feature" branch | ||
When I run `git pr` | ||
|
||
|
||
Scenario: | ||
Then I see a browser window for a new pull request on Github for the "feature" branch |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Feature: git-pr when origin is on Github over SSH | ||
|
||
Background: | ||
Given I have a feature branch named "feature" | ||
And my remote origin is on Github through SSH | ||
And I am on the "feature" branch | ||
When I run `git pr` | ||
|
||
|
||
Scenario: | ||
Then I see a browser window for a new pull request on Github for the "feature" branch |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Feature: git-pr when origin is unsupported | ||
|
||
Background: | ||
Given I have a feature branch named "feature" | ||
And I am on the "feature" branch | ||
When I run `git pr` while allowing errors | ||
|
||
|
||
Scenario: | ||
Then I get the error "Unsupported hosting service. Pull requests can only be created on Bitbucket and Github" |
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
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
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
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 |
---|---|---|
@@ -1,3 +1,29 @@ | ||
def remote_url name | ||
output_of "git remote -v | grep '#{name}.*fetch' | awk '{print $2}'" | ||
# Returns the remote URL for a new pull request for the given domain and branch | ||
def remote_pull_request_url domain, branch_name | ||
if domain == 'Bitbucket' | ||
sha = recent_commit_shas(1).join('')[0, 12] | ||
"https://bitbucket.org/Originate/git-town/pull-request/new?source=Originate%2Fgit-town%3A#{sha}%3A#{branch_name}" | ||
elsif domain == 'Github' | ||
"https://github.com/Originate/git-town/compare/#{branch_name}?expand=1" | ||
else | ||
fail "Unknown domain: #{domain}" | ||
end | ||
end | ||
|
||
|
||
# Returns the remote URL for domain / protocol | ||
def remote_url domain, protocol | ||
"#{remote_url_prefix domain, protocol}Originate/git-town.git" | ||
end | ||
|
||
|
||
# Returns the remote URL prefix for the given domain and protocol | ||
def remote_url_prefix domain, protocol | ||
case [domain, protocol] | ||
when %w(Bitbucket HTTPS) then 'https://username@bitbucket.org/' | ||
when %w(Bitbucket SSH) then 'git@bitbucket.org:' | ||
when %w(Github HTTPS) then 'https://github.com/' | ||
when %w(Github SSH) then 'git@github.com:' | ||
else fail "Unknown domain/protocol pairing: #{domain}/#{protocol}" | ||
end | ||
end |
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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
echo "open called with: $@" |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/helpers/helpers.sh" | ||
|
||
|
||
# Returns the source for a new Bitbucket pull request | ||
function bitbucket_source { | ||
sha=$(git log --format="%H" -1 | cut -c-12) | ||
echo "$repository:$sha:$branch" | sed 's/\//%2F/g' | sed 's/\:/%3A/g' | ||
} | ||
|
||
|
||
branch=$initial_branch_name | ||
domain=$(remote_domain) | ||
repository=$(remote_repository_name) | ||
|
||
if [ "$domain" == github.com ]; then | ||
pr_path="compare/$branch?expand=1" | ||
elif [ "$domain" == bitbucket.org ]; then | ||
pr_path="pull-request/new?source=$(bitbucket_source)" | ||
else | ||
echo_error_header | ||
echo_usage "Unsupported hosting service. Pull requests can only be created on Bitbucket and Github" | ||
exit_with_error | ||
fi | ||
|
||
open "https://$domain/$repository/$pr_path" |
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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.TH "GIT-PRUNE-BRANCHES" "1" "11/13/2014" "Git Town 0\&.4\&.0" "Git Town Manual" | ||
|
||
.SH "NAME" | ||
git-pr \- create a new pull request | ||
|
||
.SH "SYNOPSIS" | ||
\fIgit pr\fR | ||
|
||
.SH "DESCRIPTION" | ||
Opens a browser to a new pull request for the current branch. | ||
.br | ||
Supported only for repositories hosted on Github and Bitbucket. |
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