volley 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -39,4 +39,52 @@ task :test do
39
39
  rescue => e
40
40
  puts "#{e.message} at #{e.backtrace.first}"
41
41
  end
42
- end
42
+ end
43
+
44
+ def changelog(last=nil, single=false)
45
+ command="git --no-pager log --format='%an::::%h::::%s'"
46
+
47
+ list = `git tag`
48
+
49
+ puts "# Changelog"
50
+ puts
51
+
52
+ list.lines.reject{|e| e =~ /\.alpha/}.reverse_each do |t|
53
+ tag = t.chomp
54
+
55
+ if last
56
+ check = { }
57
+ out = []
58
+ log = `#{command} #{last}...#{tag}`
59
+ log.lines.each do |line|
60
+ (who, hash, msg) = line.split('::::')
61
+ unless check[msg]
62
+ unless msg =~ /^Merge branch/ || msg =~ /CHANGELOG/ || msg =~ /^(v|version|changes for|preparing|ready for release|ready to release|bump version)*\s*(v|version)*\d+\.\d+\.\d+/
63
+ msg.gsub(" *", "\n*").gsub(/^\*\*/, " *").lines.each do |l|
64
+ line = l =~ /^(\s+)*\*/ ? l : "* #{l}"
65
+ out << line
66
+ end
67
+ check[msg] = hash
68
+ end
69
+ end
70
+ end
71
+ puts "## #{last}:"
72
+ out.each { |e| puts e }
73
+ #puts log
74
+ puts
75
+ end
76
+
77
+ last = tag
78
+ exit if single
79
+ end
80
+ end
81
+
82
+ desc "generate changelog output"
83
+ task :changelog do
84
+ changelog
85
+ end
86
+
87
+ desc "show current changes (changelog output from HEAD to most recent tag)"
88
+ task :current do
89
+ changelog("HEAD",true)
90
+ end
@@ -36,7 +36,7 @@ Feature: Publisher
36
36
  Scenario: Duplicate Artifact
37
37
  Given I have a populated repository
38
38
  When I publish a duplicate artifact test/staging/12
39
- Then I should receive an exception
39
+ Then I should not receive an exception
40
40
 
41
41
  # TODO: make this work
42
42
  # Scenario: Duplicate Artifact force
@@ -56,8 +56,9 @@ When /^I publish a duplicate artifact (.*)$/ do |desc|
56
56
  When I publish the artifact #{desc}
57
57
  }
58
58
  begin
59
- publish(desc)
59
+ @duplicate_published = publish(desc)
60
60
  rescue => e
61
+ puts "exception: #{e.message}"
61
62
  @exception = e
62
63
  end
63
64
  end
@@ -66,7 +67,7 @@ end
66
67
  When /^I force publish a duplicate artifact (.*)$/ do |desc|
67
68
  steps %Q{
68
69
  When I publish the artifact #{desc}
69
- }
70
+ }
70
71
  begin
71
72
  publish(desc)
72
73
  rescue => e
@@ -16,6 +16,7 @@ module Volley
16
16
  end
17
17
 
18
18
  def call
19
+ return if @plan.stopped?
19
20
  Volley::Log.debug "## #{project.name}:#{@plan.name}[#{@stage}]##@name"
20
21
  self.instance_eval &@block if @block
21
22
  end
@@ -25,6 +25,7 @@ module Volley
25
25
 
26
26
  @name = name.to_sym
27
27
  @project = options[:project]
28
+ @stopped = false
28
29
  @block = block
29
30
  @files = []
30
31
  @arguments = { }
@@ -43,6 +44,7 @@ module Volley
43
44
  else
44
45
  argument :descriptor, :convert => :descriptor, :convert_opts => { :partial => true }
45
46
  end
47
+ argument :force
46
48
  end
47
49
 
48
50
  def call(options={ })
@@ -57,7 +59,13 @@ module Volley
57
59
 
58
60
  Volley::Log.info ">> #{@project.name}:#@name"
59
61
 
60
- run_actions
62
+ begin
63
+ run_actions
64
+ rescue => e
65
+ puts "plan#call error: #{e.message} at #{e.backtrace.first}"
66
+ ap self
67
+ raise e
68
+ end
61
69
  [branch, version].join(":")
62
70
  end
63
71
 
@@ -77,12 +85,21 @@ module Volley
77
85
  out.join(" ")
78
86
  end
79
87
 
80
- def run_actions(*stages)
88
+ def run_actions
81
89
  @stage_order.each do |stage|
90
+ @current_stage = stage
82
91
  @stages[stage].call
83
92
  end
84
93
  end
85
94
 
95
+ def stop
96
+ @stopped = true
97
+ end
98
+
99
+ def stopped?
100
+ @stopped
101
+ end
102
+
86
103
  def method_missing(n, *args)
87
104
  Volley::Log.warn "** plan DSL does not support method: #{n} #{args.join(',')}"
88
105
  raise "not supported"
@@ -173,7 +190,12 @@ module Volley
173
190
  :descriptor => args.descriptor,
174
191
  :args => {},
175
192
  }.merge(options)
176
- @stages[:main].add Volley::Dsl::VolleyAction.new("volley-#{plan}", o)
193
+ action = Volley::Dsl::VolleyAction.new("volley-#{plan}", o)
194
+ #if @current_stage == :post
195
+ # action.call
196
+ #else
197
+ @stages[:main].add action
198
+ #end
177
199
  end
178
200
 
179
201
  def file(file)
@@ -227,6 +249,9 @@ module Volley
227
249
  @arguments.each do |k, v|
228
250
  v.check
229
251
  end
252
+ if @arguments[:force] && Volley::Dsl.publisher
253
+ Volley::Dsl.publisher.force = true
254
+ end
230
255
  end
231
256
  end
232
257
  end
@@ -12,6 +12,17 @@ module Volley
12
12
  raise "stage instance must be set" unless @stage
13
13
  raise "plan instance must be set" unless @plan
14
14
 
15
+ @plan.action :check, :pre do
16
+ raise "branch(#{branch}) and version(#{version}) must be specified" unless branch && version
17
+ p = @plan.project.name
18
+ b = branch
19
+ v = version
20
+ if Volley::Dsl.publisher.exists?(p, b, v)
21
+ log ".. artifact exists: #{p}@#{b}:#{v}"
22
+ @plan.stop unless args.force
23
+ end
24
+ end
25
+
15
26
  @plan.action :files, :main do
16
27
  raise "branch(#{branch}) and version(#{version}) must be specified" unless branch && version
17
28
 
@@ -18,7 +18,8 @@ module Volley
18
18
  []
19
19
  end
20
20
 
21
- def branches(pr)
21
+ def branches(project)
22
+ pr = project.to_s
22
23
  r = files[:desc][pr].keys || [] rescue []
23
24
  Volley::Log.info "could not find #{pr}" unless r.count > 0
24
25
  r
@@ -27,7 +28,9 @@ module Volley
27
28
  []
28
29
  end
29
30
 
30
- def versions(pr, br)
31
+ def versions(project, branch)
32
+ pr = project.to_s
33
+ br = branch.to_s
31
34
  r = files[:desc][pr][br].keys || [] rescue []
32
35
  Volley::Log.info "could not find #{pr}@#{br}" unless r.count > 0
33
36
  r
@@ -36,7 +39,10 @@ module Volley
36
39
  []
37
40
  end
38
41
 
39
- def contents(pr, br, vr)
42
+ def contents(project, branch, version)
43
+ pr = project.to_s
44
+ br = branch.to_s
45
+ vr = version.to_s
40
46
  r = files[:desc][pr][br][vr].map {|e| e.gsub("#{pr}/#{br}/#{vr}/","")} || [] rescue []
41
47
  Volley::Log.info "could not find #{pr}@#{br}:#{vr}" unless r.count > 0
42
48
  r
@@ -46,7 +52,13 @@ module Volley
46
52
  end
47
53
 
48
54
  def exists?(project, branch, version)
49
- !files[:desc][project][branch][version].nil? rescue false
55
+ pr = project.to_s
56
+ br = branch.to_s
57
+ vr = version.to_s
58
+ !files[:desc][pr][br][vr].nil?
59
+ rescue => e
60
+ Volley::Log.debug "exists? error: #{e.message}"
61
+ false
50
62
  end
51
63
 
52
64
  def delete_project(project)
@@ -1,6 +1,8 @@
1
1
  module Volley
2
2
  module Publisher
3
3
  class Base
4
+ attr_accessor :force
5
+
4
6
  def initialize(options={ })
5
7
  @options = {
6
8
  :overwrite => false,
@@ -11,6 +13,7 @@ module Volley
11
13
  @local = optional(:local, Volley.config.directory)
12
14
  @loglevel = @debug ? :info : :debug
13
15
  @latest = {}
16
+ @force = false
14
17
 
15
18
  load_configuration
16
19
  end
@@ -60,7 +63,8 @@ module Volley
60
63
  end
61
64
 
62
65
  def push(project, branch, version, localfiles)
63
- raise ArtifactExists, "the artifact already exists" if exists?(project, branch, version)
66
+ v = version == "latest" ? latest_version(project, branch) : version
67
+ return false if exists?(project, branch, v) && !@force
64
68
 
65
69
  localfiles = [*localfiles].flatten
66
70
  log "^^ #{me}#push"
@@ -3,7 +3,7 @@ unless defined?(Volley::Version)
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 1
6
+ TINY = 2
7
7
  TAG = nil
8
8
  STRING = [MAJOR, MINOR, TINY, TAG].compact.join('.')
9
9
  end
@@ -57,14 +57,14 @@ describe Volley::Dsl::Plan do
57
57
 
58
58
  it "should handle arguments" do
59
59
  @plan.argument(:testarg)
60
- expect(@plan.arguments.count).to eq(2) # descriptor and testarg
60
+ expect(@plan.arguments.count).to eq(3) # descriptor and testarg
61
61
  @plan.call(:args => {:descriptor => "test@trunk/1",:testarg => "true"})
62
62
  expect(@plan.args.testarg).to eq("true")
63
63
  end
64
64
 
65
65
  it "should handle arguments (with remote false)" do
66
66
  @notremote.argument(:testarg)
67
- expect(@notremote.arguments.count).to eq(2) # descriptor and testarg
67
+ expect(@notremote.arguments.count).to eq(3) # descriptor and testarg
68
68
  @notremote.call(:args => {:testarg => "true"})
69
69
  expect(@notremote.args.testarg).to eq("true")
70
70
  end
@@ -63,8 +63,17 @@ shared_examples_for Volley::Publisher::Base do
63
63
  expect(@pub.latest("spec", "trunk")).to eq("spec/trunk/3")
64
64
  end
65
65
 
66
- it "should throw an exeception when trying to publish a duplicate artifact" do
67
- expect { @pub.push("spec", "trunk", "1", "./trunk-1.tgz") }.to raise_error(StandardError)
66
+ it "should fail to publish a duplicate artifact" do
67
+ expect(@pub.push("spec", "trunk", "1", "./trunk-1.tgz")).to eq(false)
68
+ end
69
+
70
+ it "should be able to force publish a duplicate artifact" do
71
+ Dir.chdir("#{root}/test/")
72
+ o = @pub.force
73
+ @pub.force = true
74
+ expect(@pub.push("spec", "trunk", "1", "./trunk-1.tgz")).to eq(true)
75
+ @pub.force = o
76
+ Dir.chdir(root)
68
77
  end
69
78
 
70
79
  it "should be able to delete a project" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000 Z
12
+ date: 2012-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp