repomen 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
- data/.ruby-version +1 -1
- data/lib/repomen/repo/handler/base.rb +12 -0
- data/lib/repomen/repo/handler/git.rb +32 -6
- data/lib/repomen/retriever.rb +39 -4
- data/lib/repomen/version.rb +1 -1
- data/test/repomen/retriever_test.rb +11 -4
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb6865efd46b5cf841cd5f99cdeadb0889bea0fd
|
4
|
+
data.tar.gz: 31abc290a77820980ad0ca1c4ae974930919cebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fe58a0f5771ceb6078557b0826e7086aa292dcd28d9094d8cd6bd722c456892c1d108d337b836d25fa91cbd8100f668a56e54a16e0412b9768cb9cf2a1d1614
|
7
|
+
data.tar.gz: c19d5e253d1378678f35e6f7feed8fa2d1310c24b09d29d83ccc1f012f852c57f294e882d890d9fd1077ce68561261de9ed848586b06f9c4d45d24a07d1e214e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.1.0
|
@@ -14,9 +14,21 @@ module Repomen
|
|
14
14
|
@path = File.join(config.work_dir, path)
|
15
15
|
end
|
16
16
|
|
17
|
+
def branch_name
|
18
|
+
raise NotImplementedError
|
19
|
+
end
|
20
|
+
|
21
|
+
def change_branch(name)
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
24
|
+
|
17
25
|
def retrieve
|
18
26
|
raise NotImplementedError
|
19
27
|
end
|
28
|
+
|
29
|
+
def revision
|
30
|
+
raise NotImplementedError
|
31
|
+
end
|
20
32
|
end
|
21
33
|
end
|
22
34
|
end
|
@@ -8,6 +8,20 @@ module Repomen
|
|
8
8
|
# @todo Uses git's CLI, since Rugged is not playing nice GitHub
|
9
9
|
# Why is that?
|
10
10
|
class Git < Base
|
11
|
+
def branch_name
|
12
|
+
branch = nil
|
13
|
+
in_dir do
|
14
|
+
branch = git 'rev-parse', '--abbrev-ref', 'HEAD'
|
15
|
+
end
|
16
|
+
branch.strip
|
17
|
+
end
|
18
|
+
|
19
|
+
def change_branch(name)
|
20
|
+
in_dir do
|
21
|
+
git :checkout, name, '--quiet'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
11
25
|
# Removes the repo from the filesystem
|
12
26
|
# @return [void]
|
13
27
|
def discard
|
@@ -22,6 +36,15 @@ module Repomen
|
|
22
36
|
else
|
23
37
|
clone_repo
|
24
38
|
end
|
39
|
+
$?.success?
|
40
|
+
end
|
41
|
+
|
42
|
+
def revision
|
43
|
+
rev = nil
|
44
|
+
in_dir do
|
45
|
+
rev = git 'rev-parse', 'HEAD'
|
46
|
+
end
|
47
|
+
rev.strip
|
25
48
|
end
|
26
49
|
|
27
50
|
private
|
@@ -30,9 +53,13 @@ module Repomen
|
|
30
53
|
`git #{args.join(' ')}`
|
31
54
|
end
|
32
55
|
|
56
|
+
def in_dir(dir = @path, &block)
|
57
|
+
Dir.chdir(dir, &block)
|
58
|
+
end
|
59
|
+
|
33
60
|
def clone_repo
|
34
61
|
FileUtils.mkdir_p path
|
35
|
-
git
|
62
|
+
git(:clone, url, path, '--quiet')
|
36
63
|
end
|
37
64
|
|
38
65
|
def git_options
|
@@ -48,14 +75,13 @@ module Repomen
|
|
48
75
|
end
|
49
76
|
|
50
77
|
def pull
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
Dir.chdir old_dir
|
78
|
+
in_dir do
|
79
|
+
git(:pull, '--quiet')
|
80
|
+
end
|
55
81
|
end
|
56
82
|
|
57
83
|
def repo_exists?
|
58
|
-
File.
|
84
|
+
File.exist?( File.join(path, ".git") )
|
59
85
|
end
|
60
86
|
end
|
61
87
|
end
|
data/lib/repomen/retriever.rb
CHANGED
@@ -14,12 +14,15 @@ module Repomen
|
|
14
14
|
class Retriever
|
15
15
|
include WithDefaultConfig
|
16
16
|
|
17
|
-
attr_reader :url
|
17
|
+
attr_reader :url
|
18
|
+
attr_reader :path
|
19
|
+
attr_reader :service
|
18
20
|
|
19
21
|
def initialize(url, config = default_config, &block)
|
20
|
-
|
21
|
-
@
|
22
|
-
@handler.
|
22
|
+
@url = url
|
23
|
+
@service = Repo::Service.for(url)
|
24
|
+
@handler = @service.handler_class.new(url, repo_dir(service), config)
|
25
|
+
@retrieved = @handler.retrieve
|
23
26
|
@path = @handler.path
|
24
27
|
if block
|
25
28
|
block.call(@path)
|
@@ -27,11 +30,43 @@ module Repomen
|
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
33
|
+
def branch_name
|
34
|
+
@handler.branch_name
|
35
|
+
end
|
36
|
+
|
37
|
+
# Changes the branch of the retrieved repo.
|
38
|
+
# @param name [String] name of the branch
|
39
|
+
def change_branch(name)
|
40
|
+
@handler.change_branch(name)
|
41
|
+
end
|
42
|
+
|
30
43
|
# Removes the repo from the filesystem
|
31
44
|
def discard_repo
|
32
45
|
@handler.discard
|
33
46
|
end
|
34
47
|
|
48
|
+
# Returns +true+ if the repo was retrieved successfully
|
49
|
+
def retrieved?
|
50
|
+
@retrieved
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns the revision of the repo.
|
54
|
+
def revision
|
55
|
+
@handler.revision
|
56
|
+
end
|
57
|
+
|
58
|
+
def repo_name
|
59
|
+
@service.repo_name
|
60
|
+
end
|
61
|
+
|
62
|
+
def service_name
|
63
|
+
@service.name
|
64
|
+
end
|
65
|
+
|
66
|
+
def user_name
|
67
|
+
@service.user_name
|
68
|
+
end
|
69
|
+
|
35
70
|
private
|
36
71
|
|
37
72
|
def repo_dir(service)
|
data/lib/repomen/version.rb
CHANGED
@@ -3,21 +3,28 @@ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
3
3
|
describe ::Repomen::Retriever do
|
4
4
|
let(:described_class) { ::Repomen::Retriever }
|
5
5
|
let(:url) { "git@bitbucket.org:atlassian_tutorial/helloworld.git" }
|
6
|
+
let(:incorrect_url) { "git@bitbucket.org:atlassian_tutorial/helloworld123.git" }
|
6
7
|
|
7
8
|
it "should retrieve the repo" do
|
8
9
|
retriever = described_class.new(url)
|
9
|
-
assert
|
10
|
+
assert retriever.retrieved?
|
11
|
+
assert File.exist?(retriever.path)
|
10
12
|
|
11
13
|
retriever.discard_repo
|
12
|
-
assert !File.
|
14
|
+
assert !File.exist?(retriever.path)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should retrieve the repo" do
|
18
|
+
retriever = described_class.new(incorrect_url)
|
19
|
+
refute retriever.retrieved?
|
13
20
|
end
|
14
21
|
|
15
22
|
it "should retrieve the repo, yield to block and discard the repo" do
|
16
23
|
@path = nil
|
17
24
|
described_class.new(url) do |path|
|
18
25
|
@path = path
|
19
|
-
assert File.
|
26
|
+
assert File.exist?(@path)
|
20
27
|
end
|
21
|
-
assert !File.
|
28
|
+
assert !File.exist?(@path)
|
22
29
|
end
|
23
30
|
end
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repomen
|
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
|
- René Föhring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '5.2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '5.2'
|
83
83
|
description: Interface wrapper for retrieving repos from GitHub and BitBucket
|
@@ -87,9 +87,9 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
91
|
-
- .ruby-gemset
|
92
|
-
- .ruby-version
|
90
|
+
- ".gitignore"
|
91
|
+
- ".ruby-gemset"
|
92
|
+
- ".ruby-version"
|
93
93
|
- Gemfile
|
94
94
|
- LICENSE.txt
|
95
95
|
- README.md
|
@@ -126,17 +126,17 @@ require_paths:
|
|
126
126
|
- lib
|
127
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- -
|
134
|
+
- - ">="
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.2.2
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Interface wrapper for retrieving repos
|