git-whence 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/git/whence.rb +27 -12
- data/lib/git/whence/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d23b4ac84ee717b785cd7de075b1a2d035509e5
|
4
|
+
data.tar.gz: d7b37d818091f7abeaa0833f83d26a780c140b66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d357a86878294eaebddc58f3b21d7e53665260c744396325ee1ef056ce4b7b612c9a2bdd51d995fae61bb5fb620639f474b12e9b2c866ac300e9c5285b6d8c5a
|
7
|
+
data.tar.gz: c069e55bb44efa2c09aa52b48c9bcd74b2972421d6f477d709ab0ded902331b90db2ed97582b1d2473bd582ef6ddcb3d965870e7a89ce8dddb54bfcc8cc3e7c2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/git/whence.rb
CHANGED
@@ -7,28 +7,43 @@ module Git::Whence
|
|
7
7
|
def run(argv)
|
8
8
|
options = parse_options(argv)
|
9
9
|
commit = argv[0]
|
10
|
-
unless system("git rev-parse --git-dir 1
|
10
|
+
unless system("git rev-parse --git-dir 2>&1 >/dev/null")
|
11
11
|
puts "Not in a git directory"
|
12
12
|
return 1
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
if is_merge?(commit)
|
16
|
+
$stderr.puts "Commit is a merge"
|
17
|
+
finished_with_commit(commit, options)
|
18
|
+
1
|
19
|
+
else
|
20
|
+
merge = find_merge(commit)
|
21
|
+
if merge
|
22
|
+
finished_with_commit(merge, options)
|
23
|
+
0
|
20
24
|
else
|
21
|
-
puts merge
|
25
|
+
$stderr.puts "Unable to find merge"
|
26
|
+
1
|
22
27
|
end
|
23
|
-
0
|
24
|
-
else
|
25
|
-
$stderr.puts "Unable to find commit"
|
26
|
-
1
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
31
32
|
|
33
|
+
def is_merge?(commit)
|
34
|
+
sh("git cat-file -p #{commit}").split("\n")[1..2].grep(/parent /).size > 1
|
35
|
+
end
|
36
|
+
|
37
|
+
def finished_with_commit(merge, options)
|
38
|
+
info = sh("git show -s --oneline #{merge}").strip
|
39
|
+
if options[:open] && (pr = info[/Merge pull request #(\d+) from /, 1]) && (url = origin)
|
40
|
+
repo = url[%r{(\w+/[-\w\.]+)}i, 1].to_s.sub(/\.git$/, "")
|
41
|
+
exec %Q{open "https://github.com/#{repo}/pull/#{pr}"}
|
42
|
+
else
|
43
|
+
puts info
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
32
47
|
def origin
|
33
48
|
remotes = sh("git remote -v").split("\n")
|
34
49
|
remotes.detect { |l| l.start_with?("origin\t") }.split(" ")[1]
|
@@ -56,7 +71,7 @@ module Git::Whence
|
|
56
71
|
end
|
57
72
|
|
58
73
|
def find_merge_simple(commit, branch)
|
59
|
-
result = sh "git log #{commit}..#{branch} --ancestry-path --merges --
|
74
|
+
result = sh "git log #{commit}..#{branch} --ancestry-path --merges --pretty='%h' 2>/dev/null | tail -n 1"
|
60
75
|
result unless result.strip.empty?
|
61
76
|
end
|
62
77
|
|
data/lib/git/whence/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-whence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
F5etKHZg0j3eHO31/i2HnswY04lqGImUu6aM5EnijFTB7PPW2KwKKM4+kKDYFdlw
|
31
31
|
/0WV1Ng2/Y6qsHwmqGg2VlYj2h4=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-05-
|
33
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
34
34
|
dependencies: []
|
35
35
|
description:
|
36
36
|
email: michael@grosser.it
|
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
�Bvh0;�9LtK�ւ�{�Y^��W\G���(�h��4���I~?Cvfcg�Vd��)2���C��+.�Svu����g�1˸
|
1
|
+
V3��QD�������9�'��=_nl���VD4��S9jr��O�h���\���������b}������x��)�������mR4��
|