jira_release 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/bin/releaser +9 -0
- data/lib/releaser.rb +118 -0
- data/lib/releaser/cli.rb +43 -0
- data/lib/releaser/version.rb +3 -0
- data/releaser.gemspec +24 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3cd0d3422b566fed999e1a913a5ca8313024969c
|
4
|
+
data.tar.gz: 9551abf3a18390e32a98c15a1b6e2f2d4d985feb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23a41666f64570a01aeb36e054d0b8b251e5690fd23c1725b04c7aa7660635e4f5348cdc5afbb3bad4ecef1f0709eab4e22da952b69c2c7e7931268af54d979e
|
7
|
+
data.tar.gz: 36d7f3d920f0f9ee3121e2e8f8ceeda710808f509b638c10bb2006175934ad1b4e1541cbcd3c55cc7041dc54f37111d4b93b0c2de69e648d61f984c55981bfcf
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Daniel Leavitt
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Releaser
|
2
|
+
|
3
|
+
Simple CLI util for generating changelogs with JIRA tickets.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install jira_release
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Run it with:
|
12
|
+
|
13
|
+
$ releaser
|
14
|
+
|
15
|
+
Help:
|
16
|
+
|
17
|
+
releaser full_log # Changelog between all tags
|
18
|
+
releaser help [COMMAND] # Describe available commands or one specific command
|
19
|
+
releaser log # Changelog between current HEAD and last tag
|
20
|
+
releaser release [tag] # Create a tag
|
21
|
+
|
22
|
+
The first time it's run it will ask for a JIRA project slug and URL. It will store these in the project git config so you won't have to enter them again.
|
23
|
+
|
24
|
+
## Todo
|
25
|
+
|
26
|
+
- Deal more elegantly with creating tags on top of one another
|
27
|
+
- Link to Github commits
|
28
|
+
- Show JIRA ticket names
|
29
|
+
- Deal better with weird repos
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/releaser
ADDED
data/lib/releaser.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require "releaser/version"
|
2
|
+
require 'rugged'
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module Releaser
|
6
|
+
class ChangeLog
|
7
|
+
attr_accessor :tag, :commits, :repo
|
8
|
+
|
9
|
+
def initialize(repo, tag, commits)
|
10
|
+
@repo, @tag, @commits = repo, tag, commits
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
tag.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def jira_prefix
|
18
|
+
repo.repo.config['releaser.jira.prefix']
|
19
|
+
end
|
20
|
+
|
21
|
+
def jira_url
|
22
|
+
repo.repo.config['releaser.jira.url']
|
23
|
+
end
|
24
|
+
|
25
|
+
def format
|
26
|
+
lines = ["Release #{name}: #{tag.time}"]
|
27
|
+
lines << "\nTickets Resolved:"
|
28
|
+
tickets.each do |t|
|
29
|
+
lines << " * #{t} - #{jira_url}/browse/#{t}"
|
30
|
+
end
|
31
|
+
|
32
|
+
lines << "\nCommits:"
|
33
|
+
commits.each do |c|
|
34
|
+
author = c.author[:name]
|
35
|
+
message = c.message.split("\n")[0]
|
36
|
+
lines << " * [#{author}] #{message} (#{c.oid[0..8]})"
|
37
|
+
end
|
38
|
+
lines.join("\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
def tickets
|
42
|
+
@tickets ||= Set.new(commits.flat_map { |c|
|
43
|
+
c.message.match(/#{jira_prefix}-\d+/) { |m| m && m[0] }
|
44
|
+
}.compact)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Repo
|
49
|
+
attr_accessor :repo
|
50
|
+
|
51
|
+
def initialize(path = '.')
|
52
|
+
@repo = Rugged::Repository.new(Rugged::Repository.discover(path))
|
53
|
+
end
|
54
|
+
|
55
|
+
def tags
|
56
|
+
@tags ||= repo.tags.map do |tagname|
|
57
|
+
rev = repo.rev_parse(tagname)
|
58
|
+
commit = rev.respond_to?(:target) ? rev.target : rev
|
59
|
+
Tag.new(tagname, commit)
|
60
|
+
end.sort_by(&:time).reverse
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_release(tag_name)
|
64
|
+
Rugged::Reference.create(repo, "refs/tags/#{tag_name}", repo.last_commit.oid)
|
65
|
+
end
|
66
|
+
|
67
|
+
def last_change_log
|
68
|
+
raise "Not enough tags in repo" if tags.length < 1
|
69
|
+
|
70
|
+
# Need at least one tag in the repo (two if it's the current commit)
|
71
|
+
if tags.first.oid == repo.last_commit.oid
|
72
|
+
start_tag = tags.first
|
73
|
+
end_tag = tags[1]
|
74
|
+
else
|
75
|
+
start_tag = Tag.new("HEAD", repo.last_commit)
|
76
|
+
end_tag = tags[0]
|
77
|
+
end
|
78
|
+
|
79
|
+
ChangeLog.new(self, start_tag, commits_between(repo.last_commit, end_tag.commit))
|
80
|
+
end
|
81
|
+
|
82
|
+
def all_change_logs
|
83
|
+
start_tag = Tag.new("HEAD", repo.last_commit)
|
84
|
+
start_on = start_tag.oid == tags.first.oid ? nil : start_tag
|
85
|
+
|
86
|
+
change_logs = []
|
87
|
+
tags.reduce(start_on) do |start_tag, end_tag|
|
88
|
+
if start_tag
|
89
|
+
commits = commits_between(start_tag.commit, end_tag.commit)
|
90
|
+
change_logs << ChangeLog.new(self, start_tag, commits)
|
91
|
+
end
|
92
|
+
end_tag
|
93
|
+
end
|
94
|
+
|
95
|
+
change_logs
|
96
|
+
end
|
97
|
+
|
98
|
+
def commits_between(start_ref, end_ref)
|
99
|
+
commits = []
|
100
|
+
repo.walk(start_ref.oid) do |commit|
|
101
|
+
break if commit.oid == end_ref.oid
|
102
|
+
commits << commit
|
103
|
+
end
|
104
|
+
|
105
|
+
commits
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
Tag = Struct.new(:name, :commit) do
|
110
|
+
extend Forwardable
|
111
|
+
|
112
|
+
def_delegators :commit, :time, :message, :oid
|
113
|
+
|
114
|
+
def author
|
115
|
+
commit.author[:name]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/lib/releaser/cli.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'releaser'
|
3
|
+
|
4
|
+
module Releaser
|
5
|
+
class CLI < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
desc "log", "Changelog between current HEAD and last tag"
|
9
|
+
def log
|
10
|
+
check_for_repo_config
|
11
|
+
say repo.last_change_log.format
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "full_log", "Changelog between all tags"
|
15
|
+
def full_log
|
16
|
+
check_for_repo_config
|
17
|
+
say repo.all_change_logs.map(&:format).join("\n\n")
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "release [tag]", "Create a tag"
|
21
|
+
def release(tag)
|
22
|
+
repo.create_release(tag)
|
23
|
+
log
|
24
|
+
end
|
25
|
+
|
26
|
+
no_commands do
|
27
|
+
def check_for_repo_config
|
28
|
+
keys = {
|
29
|
+
"releaser.jira.prefix" => "What is the JIRA project slug (eg HYFN, GS, AVON)",
|
30
|
+
"releaser.jira.url" => "What is your JIRA base URL (eg https://company.atlassian.net)",
|
31
|
+
}
|
32
|
+
|
33
|
+
keys.each do |key, prompt|
|
34
|
+
repo.repo.config[key] = ask prompt unless repo.repo.config[key]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def repo
|
39
|
+
@repo ||= Repo.new
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/releaser.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'releaser/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jira_release"
|
8
|
+
spec.version = Releaser::VERSION
|
9
|
+
spec.authors = ["Daniel Leavitt"]
|
10
|
+
spec.email = ["daniel.leavitt@gmail.com"]
|
11
|
+
spec.summary = "Script for generating changelogs with JIRA tickets"
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "rugged"
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jira_release
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Leavitt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rugged
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- daniel.leavitt@gmail.com
|
72
|
+
executables:
|
73
|
+
- releaser
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/releaser
|
83
|
+
- lib/releaser.rb
|
84
|
+
- lib/releaser/cli.rb
|
85
|
+
- lib/releaser/version.rb
|
86
|
+
- releaser.gemspec
|
87
|
+
homepage: ''
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.0.3
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Script for generating changelogs with JIRA tickets
|
111
|
+
test_files: []
|