repomen 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb6865efd46b5cf841cd5f99cdeadb0889bea0fd
4
- data.tar.gz: 31abc290a77820980ad0ca1c4ae974930919cebb
3
+ metadata.gz: d9a2002e0a9f81fb1cd5d3d0ea78fded26317280
4
+ data.tar.gz: 26eb1d304aa888a7a51b5324fb641b4b61071a81
5
5
  SHA512:
6
- metadata.gz: 2fe58a0f5771ceb6078557b0826e7086aa292dcd28d9094d8cd6bd722c456892c1d108d337b836d25fa91cbd8100f668a56e54a16e0412b9768cb9cf2a1d1614
7
- data.tar.gz: c19d5e253d1378678f35e6f7feed8fa2d1310c24b09d29d83ccc1f012f852c57f294e882d890d9fd1077ce68561261de9ed848586b06f9c4d45d24a07d1e214e
6
+ metadata.gz: f9d26bf5a96cee4c669721aa83eea98737cee817d63f7a7e7f3545ad5bd556f9eab9130299ae64c8cfc5e33413c6933f1e7955e82573f83ea185c4fb5cd9752d
7
+ data.tar.gz: b4c1b3c8784b13fa78781d6bb60cd9ba8934004d578acc55a3a0d28576866eb4f2107e05bc7d6b99d7d27fa3c34d282e6f31f6dd55334501009b5f1c699b5bd7
@@ -29,6 +29,10 @@ module Repomen
29
29
  def revision
30
30
  raise NotImplementedError
31
31
  end
32
+
33
+ def tag
34
+ raise NotImplementedError
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -1,6 +1,8 @@
1
1
  require 'fileutils'
2
2
 
3
3
  module Repomen
4
+ HandlerError = Class.new(RuntimeError)
5
+
4
6
  module Repo
5
7
  module Handler
6
8
  # Handler for git repositories
@@ -11,16 +13,21 @@ module Repomen
11
13
  def branch_name
12
14
  branch = nil
13
15
  in_dir do
14
- branch = git 'rev-parse', '--abbrev-ref', 'HEAD'
16
+ branch = git(:'rev-parse', '--abbrev-ref', 'HEAD')
15
17
  end
16
- branch.strip
18
+ branch
17
19
  end
18
20
 
19
- def change_branch(name)
21
+ def change_branch(name, update_branch = false)
20
22
  in_dir do
21
- git :checkout, name, '--quiet'
23
+ output = git(:checkout, name, '--quiet')
24
+ unless $?.success?
25
+ raise HandlerError.new("checkout failed: #{name.inspect}")
26
+ end
27
+ pull if update_branch
22
28
  end
23
29
  end
30
+ alias :checkout_revision :change_branch
24
31
 
25
32
  # Removes the repo from the filesystem
26
33
  # @return [void]
@@ -30,11 +37,13 @@ module Repomen
30
37
 
31
38
  # Retrieves the repo from +@url+
32
39
  # @return [void]
33
- def retrieve
40
+ def retrieve(branch_name = "master")
34
41
  if repo_exists?
42
+ change_branch(branch_name)
35
43
  update_repo
36
44
  else
37
45
  clone_repo
46
+ change_branch(branch_name) if $?.success?
38
47
  end
39
48
  $?.success?
40
49
  end
@@ -42,15 +51,23 @@ module Repomen
42
51
  def revision
43
52
  rev = nil
44
53
  in_dir do
45
- rev = git 'rev-parse', 'HEAD'
54
+ rev = git(:'rev-parse', 'HEAD')
55
+ end
56
+ rev
57
+ end
58
+
59
+ def tag
60
+ output = nil
61
+ in_dir do
62
+ output = git(:describe, '--exact-match', 'HEAD')
46
63
  end
47
- rev.strip
64
+ output
48
65
  end
49
66
 
50
67
  private
51
68
 
52
69
  def git(*args)
53
- `git #{args.join(' ')}`
70
+ `git #{args.join(' ')}`.chomp
54
71
  end
55
72
 
56
73
  def in_dir(dir = @path, &block)
@@ -36,9 +36,13 @@ module Repomen
36
36
 
37
37
  # Changes the branch of the retrieved repo.
38
38
  # @param name [String] name of the branch
39
- def change_branch(name)
40
- @handler.change_branch(name)
39
+ def change_branch(name, update_branch = false)
40
+ @handler.change_branch(name, update_branch)
41
+ true
42
+ rescue Repomen::HandlerError
43
+ false
41
44
  end
45
+ alias :checkout_revision :change_branch
42
46
 
43
47
  # Removes the repo from the filesystem
44
48
  def discard_repo
@@ -55,6 +59,11 @@ module Repomen
55
59
  @handler.revision
56
60
  end
57
61
 
62
+ # Returns the tag of the repo.
63
+ def tag
64
+ @handler.tag
65
+ end
66
+
58
67
  def repo_name
59
68
  @service.repo_name
60
69
  end
@@ -76,4 +85,4 @@ module Repomen
76
85
  File.join(*parts)
77
86
  end
78
87
  end
79
- end
88
+ end
@@ -1,3 +1,3 @@
1
1
  module Repomen
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repomen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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-04-06 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler