compare_linker 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +3 -3
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -1
- data/README.md +7 -4
- data/lib/compare_linker.rb +1 -0
- data/lib/compare_linker/formatter/base.rb +16 -0
- data/lib/compare_linker/formatter/markdown.rb +2 -2
- data/lib/compare_linker/formatter/text.rb +2 -2
- data/lib/compare_linker/github_link_finder.rb +17 -0
- data/lib/compare_linker/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4057ff1e3a27a008b165f7c0a8e9c66778b3c81a
|
4
|
+
data.tar.gz: a12d3dfceac57651d84af749f494af6a8ec0bfe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11a2efd1e0e96eec69a7b2b9485f2680ffbac561a8f4215b3eb7c9e21b5f3a70047a183fde4ef5f35f81789a4219eab6c7629aa5244e7db4d6d0caec2397d42c
|
7
|
+
data.tar.gz: 354661c22002a122751b6e2b8d0bd2f39de82a5e47d79aab0d7eebb9b14bacbc4be4a9e3aad8987fe926ff1e5f554364521be4406660587c4ee7bab06942f30c
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
Compare Linker
|
2
|
-
==============
|
1
|
+
# Compare Linker [![Build Status][travis-badge]][travis-link] [![Gem Version][gem-badge]][gem-link]
|
3
2
|
|
4
3
|
Create GitHub's compare view URLs for pull request from diff of `Gemfile.lock` (and post comment to pull request).
|
5
4
|
|
@@ -7,9 +6,13 @@ Create GitHub's compare view URLs for pull request from diff of `Gemfile.lock` (
|
|
7
6
|
|
8
7
|
[GitHub Compare View](https://github.com/blog/612-introducing-github-compare-view) rocks.But [diff of Gemfile.lock](https://github.com/kyanny/compare_linker_demo/pull/14/files) sucks. So I made Compare Linker.
|
9
8
|
|
10
|
-
Rack app for listening GitHub Webhook
|
11
|
-
-------------------------------------
|
9
|
+
## Rack app for listening GitHub Webhook
|
12
10
|
|
13
11
|
There's rack application for Compare Linker with GitHub's Webhook.
|
14
12
|
|
15
13
|
https://github.com/kyanny/compare_linker_rack_app
|
14
|
+
|
15
|
+
[travis-badge]: https://travis-ci.org/masutaka/compare_linker.svg?branch=master
|
16
|
+
[travis-link]: https://travis-ci.org/masutaka/compare_linker
|
17
|
+
[gem-badge]: https://badge.fury.io/rb/compare_linker.svg
|
18
|
+
[gem-link]: http://badge.fury.io/rb/compare_linker
|
data/lib/compare_linker.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
class CompareLinker
|
2
|
+
class Formatter
|
3
|
+
class Base
|
4
|
+
private
|
5
|
+
|
6
|
+
def downgrade?(old_ver, new_ver, old_tag, new_tag)
|
7
|
+
Gem::Version.new(new_ver) < Gem::Version.new(old_ver) ||
|
8
|
+
(old_tag && new_tag && Gem::Version.new(to_ver(new_tag)) < Gem::Version.new(to_ver(old_tag)))
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_ver(tag)
|
12
|
+
tag.sub(/\Av/, '')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -2,7 +2,7 @@ require "ostruct"
|
|
2
2
|
|
3
3
|
class CompareLinker
|
4
4
|
class Formatter
|
5
|
-
class Markdown
|
5
|
+
class Markdown < Base
|
6
6
|
def format(gem_info)
|
7
7
|
g = OpenStruct.new(gem_info)
|
8
8
|
|
@@ -19,7 +19,7 @@ class CompareLinker
|
|
19
19
|
"* #{g.gem_name}: (link not found) #{g.old_ver} => #{g.new_ver}"
|
20
20
|
end
|
21
21
|
|
22
|
-
if (g.
|
22
|
+
if downgrade?(g.old_ver, g.new_ver, g.old_tag, g.new_tag)
|
23
23
|
text += " (downgrade)"
|
24
24
|
end
|
25
25
|
|
@@ -2,7 +2,7 @@ require "ostruct"
|
|
2
2
|
|
3
3
|
class CompareLinker
|
4
4
|
class Formatter
|
5
|
-
class Text
|
5
|
+
class Text < Base
|
6
6
|
def format(gem_info)
|
7
7
|
g = OpenStruct.new(gem_info)
|
8
8
|
|
@@ -19,7 +19,7 @@ class CompareLinker
|
|
19
19
|
"#{g.gem_name} (link not found): #{g.old_ver} => #{g.new_ver}"
|
20
20
|
end
|
21
21
|
|
22
|
-
if (g.
|
22
|
+
if downgrade?(g.old_ver, g.new_ver, g.old_tag, g.new_tag)
|
23
23
|
text += " (downgrade)"
|
24
24
|
end
|
25
25
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "json"
|
2
2
|
require "httpclient"
|
3
|
+
require "net/http"
|
3
4
|
|
4
5
|
class CompareLinker
|
5
6
|
class GithubLinkFinder
|
@@ -22,6 +23,7 @@ class CompareLinker
|
|
22
23
|
if github_url.nil?
|
23
24
|
@homepage_uri = gem_info["homepage_uri"]
|
24
25
|
else
|
26
|
+
github_url = redirect_url(github_url)
|
25
27
|
_, @repo_owner, @repo_name = github_url.match(%r!github\.com/([^/]+)/([^/]+)!).to_a
|
26
28
|
end
|
27
29
|
end
|
@@ -29,5 +31,20 @@ class CompareLinker
|
|
29
31
|
def repo_full_name
|
30
32
|
"#{@repo_owner}/#{repo_name}"
|
31
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def redirect_url(url, limit = 5)
|
38
|
+
raise ArgumentError, 'HTTP redirect too deep' if limit <= 0
|
39
|
+
response = Net::HTTP.get_response(URI.parse(url))
|
40
|
+
case response
|
41
|
+
when Net::HTTPSuccess
|
42
|
+
url
|
43
|
+
when Net::HTTPRedirection
|
44
|
+
redirect_url(response['location'], limit - 1)
|
45
|
+
else
|
46
|
+
raise ItemNotFound
|
47
|
+
end
|
48
|
+
end
|
32
49
|
end
|
33
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compare_linker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kensuke Nagae
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- compare_linker.gemspec
|
99
99
|
- guides/jenkins_setup_guide.md
|
100
100
|
- lib/compare_linker.rb
|
101
|
+
- lib/compare_linker/formatter/base.rb
|
101
102
|
- lib/compare_linker/formatter/markdown.rb
|
102
103
|
- lib/compare_linker/formatter/text.rb
|
103
104
|
- lib/compare_linker/github_link_finder.rb
|