qa_release_tasks 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/git/wiki.rb ADDED
@@ -0,0 +1,96 @@
1
+ module Git
2
+ class Wiki
3
+ require 'enumerator'
4
+ include CLI
5
+ include Commands
6
+ require 'pivotal-tracker'
7
+ require 'yaml'
8
+
9
+ attr_reader :options
10
+ def initialize(options = {})
11
+ @options = options
12
+ end
13
+
14
+ def annotate!
15
+ assert_is_git_repo
16
+ initialize_pivotal
17
+ tags = get_tags.reverse
18
+ error "No version tags available." if tags.empty?
19
+
20
+ if options[:all]
21
+ start_index = 0
22
+ end_index = tags.length - 1
23
+ else
24
+ start_tag = options[:from] || ask("Start at which tag?", tags[0], tags)
25
+ start_index = tags.index(start_tag)
26
+ end_tag = options[:to] || ask("End at which tag?", tags[start_index + 1] || tags[start_index], tags)
27
+ end_index = tags.index(end_tag) + 1 # include end tag
28
+ end
29
+
30
+ start = tags[start_index]
31
+ finish = tags[end_index]
32
+ range = ''
33
+ range << "refs/tags/#{finish}.." if finish # log until end tag if there is an end tag
34
+ range << "refs/tags/#{start}"
35
+ log = `git log --no-merges --pretty=format:"%h %s" #{range}`.strip.split("\n")
36
+ project_name = `pwd`.chomp.split('/').last
37
+ # stories = { 12345 => { 'abc123' => "foo", 'def343' => "bar" } }
38
+ stories = Hash.new{|hash, key| hash[key] = {}}
39
+ log.each do |log_line|
40
+ # (commit, pair, pivotal, subject) = log_line.split(/\s+/, 4)
41
+ #[(.+?)]\s*[(\d+)](.+)
42
+ (match, commit, pair, pivotal, subject) = *log_line.match(/(.+?) \[(.*)\]\s*\[\#?(\d+)\](.*)/)
43
+ stories[pivotal.to_i][commit] = { :pair => pair, :message => subject.strip } if match
44
+ end
45
+
46
+ table_start
47
+ Struct.new("UnknownStory", :id, :name, :story_type, :url)
48
+ stories.each do |story_id, commits|
49
+ story = @pivotal.stories.find(story_id) || Struct::UnknownStory.new(story_id, 'No Pivotal Story Available', 'Unknown', nil)
50
+
51
+ row = "|-\n| "
52
+ row += story.url ? "[#{story.url} #{story.id}]" : "#{story.id}"
53
+ row += "\n| #{story.name}\n| #{story.story_type.capitalize}\n|\n{|\n"
54
+ commits.each do |commit, details|
55
+ row += "|-\n| [http://github.com/primedia/#{project_name}/commit/#{commit} #{commit}]\n| #{details[:pair]}\n| #{details[:message]}\n"
56
+ end
57
+ row += "|}"
58
+
59
+ puts row
60
+ end
61
+ table_end
62
+ puts
63
+ end
64
+
65
+ private
66
+
67
+ def initialize_pivotal
68
+ if File.exists?('config/pivotal.yml')
69
+ config = YAML.load_file("config/pivotal.yml")
70
+ end
71
+ if !File.exists?('config/pivotal.yml') || config.nil? || config['token'].nil? || config['project'].nil?
72
+ puts "You need to create config/pivotal.yml with the following contents:"
73
+ puts "\ttoken: _____PIVOTAL TOKEN ID____________"
74
+ puts "\tproject: _______ PIVOTAL PROJECT ID _______"
75
+ exit
76
+ end
77
+
78
+ PivotalTracker::Client.token = config['token']
79
+ @pivotal = PivotalTracker::Project.find(config['project'])
80
+ end
81
+ def table_start
82
+ puts <<'EOF'
83
+ {| border="1"
84
+ |+Release Contents
85
+ ! Pivotal #
86
+ ! User Story
87
+ ! Story Type
88
+ ! Git Commits
89
+ |-
90
+ EOF
91
+ end
92
+ def table_end
93
+ puts "|}"
94
+ end
95
+ end
96
+ end
@@ -3,10 +3,11 @@ require 'cli'
3
3
  require 'git/commands'
4
4
  require 'git/release_notes'
5
5
  require 'git/tagger'
6
+ require 'git/wiki'
6
7
  require 'tasks/qa_release'
7
8
 
8
9
  module QaReleaseTasks
9
- VERSION = '1.1.0'
10
+ VERSION = '1.2.0'
10
11
 
11
12
  def self.version
12
13
  VERSION
@@ -14,5 +14,10 @@ namespace :qa do
14
14
  task :notes do
15
15
  Git::ReleaseNotes.new.annotate!
16
16
  end
17
+
18
+ desc "Add release notes for a given tag in wiki format"
19
+ task :wiki do
20
+ Git::Wiki.new.annotate!
21
+ end
17
22
  end
18
23
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 1.1.0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jason Noble
@@ -15,7 +15,7 @@ autorequire: qa_release_tasks
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-21 00:00:00 -04:00
18
+ date: 2010-06-24 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -37,6 +37,7 @@ files:
37
37
  - lib/git/commands.rb
38
38
  - lib/git/release_notes.rb
39
39
  - lib/git/tagger.rb
40
+ - lib/git/wiki.rb
40
41
  - lib/qa_release_tasks.rb
41
42
  - lib/tasks/qa_release.rake
42
43
  - lib/tasks/qa_release.rb