open_git 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/opr +15 -1
- data/lib/open_git/git.rb +8 -1
- data/lib/open_git/open.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b65d60f92b9722efe5a45c713edb979b66ea93792559599c04ea47a81230e87a
|
4
|
+
data.tar.gz: 3ea0f1cc15675b04cea3f9160d7c037840d0c0758cb5b919a0cda8cf48c3f4ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc15127c4a6aa9a2ba0e036848c645b5cbecfa331e337ae429aa35a66fd2f4f780a64c9f65cbbf2710cdaabe4ec90373e5a3d2611f2e7578840ff45192885161
|
7
|
+
data.tar.gz: e664adfabe313928b1e424e2cd4a1cd01fe558134bd8eb855a03d6e1e0b723c1705352efcb6b97709e4ced89f0eb42dd7e6a3f22ce1288745dc81acf5dc3e141
|
data/bin/opr
CHANGED
@@ -3,17 +3,31 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'open_git'
|
6
|
+
require 'English'
|
6
7
|
|
7
8
|
if ARGV.size > 1
|
8
9
|
puts "usage: opr [<branch>]"
|
9
10
|
else
|
10
11
|
begin
|
11
|
-
|
12
|
+
if OpenGit::Git.upstream == ""
|
13
|
+
output = `git push --set-upstream #{OpenGit::Git.remote} #{OpenGit::Git.branch}`
|
14
|
+
if $CHILD_STATUS != 0
|
15
|
+
puts "opr: Error trying to push new branch to remote."
|
16
|
+
puts output
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
system "open #{OpenGit::Open.github_new_pull_request ARGV[0]}"
|
20
|
+
else
|
21
|
+
# upstream has been set and a pull request may already exist
|
22
|
+
system "open #{OpenGit::Open.github_pull_request ARGV[0]}"
|
23
|
+
end
|
12
24
|
rescue OpenGit::Git::NoGitRepoError
|
13
25
|
puts "opr: No git repo found. Please use opr in a git repo."
|
14
26
|
rescue OpenGit::Git::NoRemoteError
|
15
27
|
puts "opr: No git remote found. Setup a git remote before using opr."
|
16
28
|
rescue OpenGit::Git::InvalidRemoteError
|
17
29
|
puts "opr: could not find specified remote."
|
30
|
+
rescue StandardError => e
|
31
|
+
puts "opr: unexpected internal error."
|
18
32
|
end
|
19
33
|
end
|
data/lib/open_git/git.rb
CHANGED
@@ -34,7 +34,14 @@ module OpenGit
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.branch
|
37
|
-
|
37
|
+
`git rev-parse --abbrev-ref HEAD`.strip
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.upstream
|
41
|
+
up = `git rev-parse --abbrev-ref --symbolic-full-name @{u}`.strip
|
42
|
+
# ignore output if error code 128, no upstream error
|
43
|
+
up = '' if $CHILD_STATUS == 128
|
44
|
+
up
|
38
45
|
end
|
39
46
|
end
|
40
47
|
end
|
data/lib/open_git/open.rb
CHANGED