git_pr 0.0.14.beta12 → 0.0.14.beta15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/git-pr +16 -1
- data/lib/git_pr/merge.rb +19 -2
- data/lib/git_pr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af4b86e0e341d7d744ae5afa8d4e74302e19272
|
4
|
+
data.tar.gz: 0a4ac4c9e319ddee330a21780a45a6c5ae3ae4be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7ee12e83f1a3a567fcd692532bd47c2285defa6b7dc00f72ffd5c992e1d637625877a50d198e2412b337b126e24ea509730f1bd848fdd7fdf67cf5d8d75d8e1
|
7
|
+
data.tar.gz: 56bc28a766236be23ac16c98ee31493bbd024d5c9e41a2e07bb3866f9f7861bd288b3b759d1e2737d4e49292c8ab519baa03d63e806fe2463716cad51c06008c
|
data/bin/git-pr
CHANGED
@@ -301,7 +301,22 @@ when "open"
|
|
301
301
|
remote = git.find_remote_for_local_branch source
|
302
302
|
remote_url = remote ? remote.url : nil
|
303
303
|
unless remote_url and remote_url.match /github\.com/
|
304
|
-
puts
|
304
|
+
puts <<EOS
|
305
|
+
|
306
|
+
Branch '#{source}' has never been pushed to GitHub,
|
307
|
+
or was pushed without setting the upstream branch.
|
308
|
+
|
309
|
+
To fix this problem, try running:
|
310
|
+
|
311
|
+
git branch --set-upstream-to=<your_remote>/#{source} #{source}
|
312
|
+
|
313
|
+
In the future, you can avoid this problem by making your first push
|
314
|
+
with the --set-upstream argument(or the shorthand, -u):
|
315
|
+
|
316
|
+
git push --set-upstream <your_remote> #{source}
|
317
|
+
git push -u <your_remote> #{source}
|
318
|
+
|
319
|
+
EOS
|
305
320
|
exit -1
|
306
321
|
end
|
307
322
|
github_source_owner = remote_url.match(/git@github.com:(.*)\//)[1]
|
data/lib/git_pr/merge.rb
CHANGED
@@ -16,6 +16,13 @@ module GitPr
|
|
16
16
|
[source_remote, target_remote]
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.are_branches_identical? git, branch_one, branch_two
|
20
|
+
sha1 = `git rev-parse --short #{branch_one}`.strip!
|
21
|
+
sha2 = `git rev-parse --short #{branch_two}`.strip!
|
22
|
+
return (sha1 == sha2) &&
|
23
|
+
git.diff(branch_one, branch_two).stats[:total][:files] == 0
|
24
|
+
end
|
25
|
+
|
19
26
|
def self.merge_pull_cleanly git, pull, command_options
|
20
27
|
unless command_options.yolo
|
21
28
|
case pull.state
|
@@ -84,6 +91,15 @@ EOS
|
|
84
91
|
target_remote.fetch
|
85
92
|
end
|
86
93
|
|
94
|
+
current_branch = `git rev-parse --abbrev-ref HEAD`.strip!
|
95
|
+
at_exit do
|
96
|
+
# Restore the branch we started on, if it hasn't been deleted as part of
|
97
|
+
# completing a merge.
|
98
|
+
if git.branches[current_branch]
|
99
|
+
GitPr.run_command "git checkout -q #{current_branch}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
87
103
|
# Get the target branch up to date
|
88
104
|
puts "Update branch '#{target_branch}' from remote"
|
89
105
|
GitPr.run_command "git checkout -q #{target_branch}"
|
@@ -94,7 +110,7 @@ EOS
|
|
94
110
|
# If the local target branch differs from the remote target branch, they
|
95
111
|
# must be reconciled manually.
|
96
112
|
remote_target_branch = "#{target_remote}/#{target_branch}"
|
97
|
-
|
113
|
+
unless GitPr.are_branches_identical? git, "remotes/#{remote_target_branch}", target_branch
|
98
114
|
puts "Local branch '#{target_branch}' differs from remote branch '#{remote_target_branch}'. Please reconcile before continuing.".red
|
99
115
|
exit -1
|
100
116
|
end
|
@@ -104,7 +120,7 @@ EOS
|
|
104
120
|
# manually.
|
105
121
|
remote_source_branch = "#{source_remote}/#{source_branch}"
|
106
122
|
if git.is_local_branch? source_branch and
|
107
|
-
git
|
123
|
+
not GitPr.are_branches_identical? git, "remotes/#{remote_source_branch}", source_branch
|
108
124
|
puts "Local branch '#{source_branch}' differs from remote branch '#{remote_source_branch}'. Please reconcile before continuing.".red
|
109
125
|
exit -1
|
110
126
|
end
|
@@ -115,6 +131,7 @@ EOS
|
|
115
131
|
puts "Create temporary branch '#{rebase_branch}'"
|
116
132
|
if git.is_local_branch? rebase_branch
|
117
133
|
puts "Local rebase branch '#{rebase_branch}' already exists. Please remove before continuing.".red
|
134
|
+
GitPr.run_command "git checkout -q #{current_branch}"
|
118
135
|
exit -1
|
119
136
|
end
|
120
137
|
GitPr.run_command "git checkout -q -b #{rebase_branch} #{remote_source_branch}"
|
data/lib/git_pr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.14.
|
4
|
+
version: 0.0.14.beta15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Sharon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|