make_release 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/make_release/git.rb +22 -8
- data/lib/make_release/globals.rb +2 -2
- data/lib/make_release/options.rb +2 -3
- data/lib/make_release/stories.rb +15 -18
- data/lib/make_release.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8ad20920bcb4dc6f1ff4650fbba7cdc47c293df
|
4
|
+
data.tar.gz: fb4189046c3fde04e76c88ce9f7fb934f22ece3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6036c7b2f5e75c0b98a5b13e2e05c70ca5721dbe6a468a6c2fb9d9e66b85d4fa688452217a460e141daa51b9e6f6a34a0134edd67367914f34413c833ea0e6bb
|
7
|
+
data.tar.gz: 78948f0991ac3ae3737bd66522637c9d41095ca147d255d66cde5e6adc6c863942329f9357392a35c819a4a8baacec310d2dfb7e6161fba64c399e195683b36f
|
data/lib/make_release/git.rb
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
require 'open3'
|
2
2
|
|
3
3
|
module MakeRelease
|
4
|
-
|
4
|
+
class Git
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
def initialize(dir = '.')
|
7
|
+
raise StandardError, "Directory '#{dir}' is not valid" unless Dir.exist?(dir)
|
8
|
+
raise RuntimeError, "Doesn't look like '#{dir}' is a Git repository" unless Dir.exist?(File.join(dir, '.git'))
|
9
|
+
|
10
|
+
@working_dir = dir
|
11
|
+
end
|
12
|
+
|
13
|
+
def log(branch)
|
14
|
+
raise RuntimeError, "Invalid branch: #{branch}" unless branch_valid? branch
|
15
|
+
run_command("git log --no-merges --pretty='%H|%s' #{branch}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def branch_valid?(branch)
|
19
|
+
run_command("git branch --list #{branch}")[0] =~ /#{branch}/
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def run_command(cmd)
|
25
|
+
Open3.popen3(cmd, chdir: @working_dir) do |i, o, e, t|
|
26
|
+
raise RuntimeError, "Error on command: #{cmd}" if t.value != 0
|
12
27
|
o.read.split("\n")
|
13
28
|
end
|
14
29
|
end
|
15
|
-
|
16
30
|
end
|
17
31
|
end
|
data/lib/make_release/globals.rb
CHANGED
@@ -2,7 +2,7 @@ module MakeRelease
|
|
2
2
|
module Globals
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
VERSION = '0.
|
5
|
+
VERSION = '0.2.0'
|
6
6
|
IDENT = 'make_release'
|
7
7
|
BINIDENT = 'mkrelease'
|
8
8
|
AUTHOR = 'Donovan C. Young'
|
@@ -11,6 +11,6 @@ module MakeRelease
|
|
11
11
|
DESCRIPTION = %q{Merges a list of JIRA stories from multiple branches into a release candidate}
|
12
12
|
HOMEPAGE = "https://github.com/dyoung522/#{IDENT}"
|
13
13
|
LICENSE = 'MIT'
|
14
|
-
VSTRING = "#{
|
14
|
+
VSTRING = "#{BINIDENT} v.#{VERSION} - #{AUTHOR}, 2015"
|
15
15
|
end
|
16
16
|
end
|
data/lib/make_release/options.rb
CHANGED
@@ -35,8 +35,7 @@ module MakeRelease
|
|
35
35
|
if Dir.exist?(dir)
|
36
36
|
options.directory = dir
|
37
37
|
else
|
38
|
-
|
39
|
-
exit 2
|
38
|
+
raise RuntimeError, "ENOEXIST: Directory does not exist -> #{dir}"
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
@@ -64,7 +63,7 @@ module MakeRelease
|
|
64
63
|
|
65
64
|
opts.on('-h', '--help', 'Show this message') { puts Globals::VSTRING + "\n\n"; puts opts; exit 255; }
|
66
65
|
opts.on('-V', '--version', 'Show version (and exit)') { puts Globals::VSTRING; exit 255; }
|
67
|
-
opts.on('--diff', "Display a list of stories from all sources which haven't been merged into master") { options.diff = true }
|
66
|
+
opts.on('-D', '--diff', "Display a list of stories from all sources which haven't been merged into master") { options.diff = true }
|
68
67
|
opts.on('--dryrun', %q{Don't actually modify any files, just show what would happen}) { options.dryrun = true }
|
69
68
|
opts.on('--debug', 'Run with debugging options (use with caution)') { options.debug = true }
|
70
69
|
end
|
data/lib/make_release/stories.rb
CHANGED
@@ -4,13 +4,13 @@ require 'make_release/git'
|
|
4
4
|
module MakeRelease
|
5
5
|
class Stories
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@options
|
9
|
-
@stories
|
7
|
+
def initialize(opts = Options.defaults)
|
8
|
+
@options = opts
|
9
|
+
@stories = opts[:stories] || {}
|
10
10
|
@directory = opts[:directory] || '.'
|
11
|
-
@branches
|
11
|
+
@branches = _get_branches(opts[:master], opts[:source])
|
12
12
|
|
13
|
-
|
13
|
+
_get_stories if @stories == {}
|
14
14
|
end
|
15
15
|
|
16
16
|
attr_accessor :branches, :directory
|
@@ -23,13 +23,6 @@ module MakeRelease
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def to_s
|
27
|
-
@stories.each do |branch, stories|
|
28
|
-
puts "#{branch.capitalize} -->"
|
29
|
-
stories.each { |s| puts s.to_s }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
26
|
def source
|
34
27
|
@branches[1, @branches.size]
|
35
28
|
end
|
@@ -41,13 +34,13 @@ module MakeRelease
|
|
41
34
|
def master=(new_master)
|
42
35
|
@stories[master] = []
|
43
36
|
@branches[0] = new_master
|
44
|
-
|
37
|
+
_get_stories(new_master)
|
45
38
|
end
|
46
39
|
|
47
40
|
def shas
|
48
41
|
source.map do |branch|
|
49
42
|
stories[branch].map { |s| s.sha }
|
50
|
-
end.flatten
|
43
|
+
end.flatten.reverse
|
51
44
|
end
|
52
45
|
|
53
46
|
def source_stories
|
@@ -60,13 +53,15 @@ module MakeRelease
|
|
60
53
|
story_index.values
|
61
54
|
end
|
62
55
|
|
63
|
-
def add_story(
|
56
|
+
def add_story(branch, story)
|
64
57
|
(@stories[branch] ||= []).push story
|
65
58
|
end
|
66
59
|
|
67
|
-
def find(
|
60
|
+
def find(branch, sha)
|
68
61
|
raise ArgumentError, "Invalid environment #{branch}" unless @branches.include?(branch)
|
62
|
+
|
69
63
|
@stories[branch].each { |story| return true if story.sha == sha }
|
64
|
+
|
70
65
|
false
|
71
66
|
end
|
72
67
|
|
@@ -91,9 +86,11 @@ module MakeRelease
|
|
91
86
|
branches.flatten
|
92
87
|
end
|
93
88
|
|
94
|
-
def
|
89
|
+
def _get_stories(branches = @branches)
|
90
|
+
git = Git.new(@directory)
|
91
|
+
|
95
92
|
branches.to_a.each do |branch|
|
96
|
-
|
93
|
+
git.log(branch).each do |line|
|
97
94
|
add_story branch, Story.new(line)
|
98
95
|
end
|
99
96
|
end
|
data/lib/make_release.rb
CHANGED