knife-changelog 0.0.6 → 0.0.7

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: 1bbd51d2aca135fbd9769d8daf1dd01a7eb59f57
4
- data.tar.gz: 7ae04bda29b8e5d5df002a8a325bffbe24de36b9
3
+ metadata.gz: 34152ac50aad8ec013bfbd082912c1fb3f4dd69b
4
+ data.tar.gz: 2b7628639511e0b1f6b2ea5209ae41e26695d28f
5
5
  SHA512:
6
- metadata.gz: 8318f3899126b60f785c8688450f51301e5520e468baf93dfa5492b21700a3822bccd8947be6c0f7a3756b11faea674240598b49c65a62d415f20fa79fa19bc5
7
- data.tar.gz: 1089434a0c3335385a7ae2c0d14d5bf01161500560949d08f44c6f5f002c56644d186922ca594bebe9d4f3f3e3037e2b2bb4a028d38d0215157317b49ad9c688
6
+ metadata.gz: 16ee8cd9af20fc1a9b15f498314ccdee066591eca64a30b66cac25486b49350dad72b95479ffb8b7767401ec745bb71faaf161d1b7de2bd073976a0773d0c334
7
+ data.tar.gz: 051449529d72c8223eeefd7d3798b3e4aeab3165c4a4a49bf471a02af6468343327726bc6c35d56fb4d9a4a419a19195de451e2e894d2579b93416db97d2e7be
@@ -102,7 +102,7 @@ class Chef
102
102
  when /github.com\/(.*)(.git)?/
103
103
  options = {
104
104
  :github => $1,
105
- :revision => 'v' + version_for(name),
105
+ :revision => version_for(name),
106
106
  }
107
107
  location = Berkshelf::GithubLocation.new dep, options
108
108
  handle_git(location)
@@ -111,11 +111,28 @@ class Chef
111
111
  end
112
112
  end
113
113
 
114
+ def revision_exists?(dir, revision)
115
+ Log.debug "Testing existence of #{revision}"
116
+ revlist = Mixlib::ShellOut.new("git rev-list --quiet #{revision}", :cwd => dir)
117
+ revlist.run_command
118
+ not revlist.error?
119
+ end
120
+
121
+ def detect_cur_revision(dir, rev)
122
+ unless revision_exists?(dir, rev)
123
+ prefixed_rev = 'v' + rev
124
+ return prefixed_rev if revision_exists?(dir, prefixed_rev)
125
+ fail "#{rev} is not a valid revision"
126
+ end
127
+ rev
128
+ end
129
+
114
130
  def handle_git(location)
115
131
  tmp_dir = shallow_clone(@tmp_prefix,location.uri)
116
132
 
117
133
  rev_parse = location.instance_variable_get(:@rev_parse)
118
134
  cur_rev = location.revision.rstrip
135
+ cur_rev = detect_cur_revision(tmp_dir, cur_rev)
119
136
  ls_tree = Mixlib::ShellOut.new("git ls-tree -r #{rev_parse}", :cwd => tmp_dir)
120
137
  ls_tree.run_command
121
138
  changelog = ls_tree.stdout.lines.find { |line| line =~ /\s(changelog.*$)/i }
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Changelog
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregoire Seux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-23 00:00:00.000000000 Z
11
+ date: 2015-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler