make_release 0.1.1 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fbb23cdf86da813754fd4e9c9a91a152ee45600
4
- data.tar.gz: ac4a0c3b38dc3015566c298ed0120eae68cbf81e
3
+ metadata.gz: c8ad20920bcb4dc6f1ff4650fbba7cdc47c293df
4
+ data.tar.gz: fb4189046c3fde04e76c88ce9f7fb934f22ece3c
5
5
  SHA512:
6
- metadata.gz: bdc3e3cc59912ed6ed74b017b6335f3ff23692142e40ba21d090aedeb6d12b6f26f440bc17dad7fe2f7ca5ca3c5efca2b17936be600d8a0f03c744816de43d9c
7
- data.tar.gz: d663f98969f8810629ecb41aed8df0a8fd57c7e61d367827be19a2fa96663a98ae29f757fddd6b8e7a0fb91004b1c634250cc5b922fe59995ad733f71b368f02
6
+ metadata.gz: 6036c7b2f5e75c0b98a5b13e2e05c70ca5721dbe6a468a6c2fb9d9e66b85d4fa688452217a460e141daa51b9e6f6a34a0134edd67367914f34413c833ea0e6bb
7
+ data.tar.gz: 78948f0991ac3ae3737bd66522637c9d41095ca147d255d66cde5e6adc6c863942329f9357392a35c819a4a8baacec310d2dfb7e6161fba64c399e195683b36f
@@ -1,17 +1,31 @@
1
1
  require 'open3'
2
2
 
3
3
  module MakeRelease
4
- module Git
4
+ class Git
5
5
 
6
- def self.log(dir, branch)
7
- cmd = "git log --no-merges --pretty='%H|%s' #{branch}"
8
- Open3.popen3(cmd, chdir: dir) do |i,o,e,t|
9
- if t.value != 0
10
- raise RuntimeError, "Unable to obtain gitlog for #{branch} in #{dir}"
11
- end
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
@@ -2,7 +2,7 @@ module MakeRelease
2
2
  module Globals
3
3
  require 'yaml'
4
4
 
5
- VERSION = '0.1.1'
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 = "#{IDENT} v.#{VERSION} - #{AUTHOR}, 2015"
14
+ VSTRING = "#{BINIDENT} v.#{VERSION} - #{AUTHOR}, 2015"
15
15
  end
16
16
  end
@@ -35,8 +35,7 @@ module MakeRelease
35
35
  if Dir.exist?(dir)
36
36
  options.directory = dir
37
37
  else
38
- puts "Whoops: '#{dir}' is not a valid directory."
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
@@ -4,13 +4,13 @@ require 'make_release/git'
4
4
  module MakeRelease
5
5
  class Stories
6
6
 
7
- def initialize( opts = Options.defaults )
8
- @options = opts
9
- @stories = opts[:stories] || {}
7
+ def initialize(opts = Options.defaults)
8
+ @options = opts
9
+ @stories = opts[:stories] || {}
10
10
  @directory = opts[:directory] || '.'
11
- @branches = _get_branches(opts[:master], opts[:source])
11
+ @branches = _get_branches(opts[:master], opts[:source])
12
12
 
13
- get_stories if @stories == {}
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
- get_stories(new_master)
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( branch, story )
56
+ def add_story(branch, story)
64
57
  (@stories[branch] ||= []).push story
65
58
  end
66
59
 
67
- def find( branch, sha )
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 get_stories(branches = @branches)
89
+ def _get_stories(branches = @branches)
90
+ git = Git.new(@directory)
91
+
95
92
  branches.to_a.each do |branch|
96
- Git.log(@directory, branch).each do |line|
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
@@ -18,7 +18,12 @@ module MakeRelease
18
18
 
19
19
  puts opts.inspect if opts.debug
20
20
 
21
- stories = Stories.new(opts)
21
+ begin
22
+ stories = Stories.new(opts)
23
+ rescue RuntimeError => error
24
+ puts error
25
+ exit 1
26
+ end
22
27
 
23
28
  puts stories.inspect if opts.debug
24
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: make_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan C. Young