vershunt 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/vershunt +19 -0
- data/lib/msp_release.rb +153 -0
- data/lib/msp_release/build.rb +64 -0
- data/lib/msp_release/cli.rb +90 -0
- data/lib/msp_release/cli/branch.rb +97 -0
- data/lib/msp_release/cli/build.rb +99 -0
- data/lib/msp_release/cli/bump.rb +49 -0
- data/lib/msp_release/cli/checkout.rb +196 -0
- data/lib/msp_release/cli/distrib.rb +7 -0
- data/lib/msp_release/cli/help.rb +14 -0
- data/lib/msp_release/cli/new.rb +62 -0
- data/lib/msp_release/cli/push.rb +29 -0
- data/lib/msp_release/cli/reset.rb +17 -0
- data/lib/msp_release/cli/status.rb +46 -0
- data/lib/msp_release/debian.rb +229 -0
- data/lib/msp_release/exec.rb +120 -0
- data/lib/msp_release/git.rb +145 -0
- data/lib/msp_release/log.rb +48 -0
- data/lib/msp_release/make_branch.rb +29 -0
- data/lib/msp_release/options.rb +35 -0
- data/lib/msp_release/project.rb +41 -0
- data/lib/msp_release/project/base.rb +63 -0
- data/lib/msp_release/project/debian.rb +168 -0
- data/lib/msp_release/project/gem.rb +74 -0
- data/lib/msp_release/project/git.rb +76 -0
- data/lib/msp_release/project/ruby.rb +40 -0
- data/lib/msp_release/version.rb +3 -0
- metadata +116 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
#
|
2
|
+
# This kind of project stores the version in the debian changelog
|
3
|
+
#
|
4
|
+
module MSPRelease
|
5
|
+
module Project::Debian
|
6
|
+
|
7
|
+
class BuildResult
|
8
|
+
def initialize(dir, project)
|
9
|
+
@dir = dir
|
10
|
+
@project = project
|
11
|
+
|
12
|
+
looking_for = project.changelog.version.to_s
|
13
|
+
changes_file = find_changes_file(looking_for)
|
14
|
+
if changes_file && File.exists?(changes_file)
|
15
|
+
@changes_file = changes_file
|
16
|
+
else
|
17
|
+
raise NoChangesFileError, looking_for
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :changes_file
|
22
|
+
|
23
|
+
alias :package :changes_file
|
24
|
+
|
25
|
+
def files
|
26
|
+
dir = File.dirname(changes_file)
|
27
|
+
changes = File.read(changes_file).split("\n")
|
28
|
+
files_start = changes.index {|l| /^Files: $/.match(l) } + 1
|
29
|
+
changes[files_start..-1].map {|l| File.join(dir, l.split(" ").last) } +
|
30
|
+
[changes_file]
|
31
|
+
end
|
32
|
+
|
33
|
+
def available_changes_files
|
34
|
+
Dir["#{@dir}/*.changes"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def changes_pattern
|
38
|
+
/#{@project.source_package_name}_([^_]+)_([^\.]+)\.changes/
|
39
|
+
end
|
40
|
+
|
41
|
+
def find_changes_file(version_string)
|
42
|
+
available_changes_files.find { |fname|
|
43
|
+
(m = changes_pattern.match(File.basename(fname))) && m && (m[1] == version_string)
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
DEFAULT_PATH = "debian/msp/changelog"
|
49
|
+
|
50
|
+
def write_version(new_version)
|
51
|
+
debian_version = Debian::Versions::Unreleased.new_from_version(new_version)
|
52
|
+
changelog.add(debian_version, "New version")
|
53
|
+
|
54
|
+
defined?(super) ?
|
55
|
+
Array(super).push(changelog.fname) :
|
56
|
+
[changelog.fname]
|
57
|
+
end
|
58
|
+
|
59
|
+
def version
|
60
|
+
changelog.version.to_version
|
61
|
+
end
|
62
|
+
|
63
|
+
def changelog_path
|
64
|
+
@changelog_path || 'debian/changelog'
|
65
|
+
end
|
66
|
+
|
67
|
+
def source_package_name
|
68
|
+
debian_dir = File.dirname(File.join(@dir, changelog_path))
|
69
|
+
control_file = File.join(debian_dir + '/control')
|
70
|
+
source_line = MSPRelease::Exec.exec("grep Source: #{control_file}")
|
71
|
+
match = /^Source: (.+)$/.match(source_line)
|
72
|
+
match && match[1]
|
73
|
+
end
|
74
|
+
|
75
|
+
def name
|
76
|
+
source_package_name
|
77
|
+
end
|
78
|
+
|
79
|
+
def changelog
|
80
|
+
Debian.new(@dir, changelog_path)
|
81
|
+
end
|
82
|
+
|
83
|
+
def next_version_for_release(options = {})
|
84
|
+
deb_version = changelog.version
|
85
|
+
distribution = options[:distribution] || changelog.distribution
|
86
|
+
|
87
|
+
new_version =
|
88
|
+
if deb_version.to_version != version
|
89
|
+
LOG.warn "Warning: project version (#{version.to_s}) " +
|
90
|
+
"did not match changelog version (#{deb_version.to_s}), project " +
|
91
|
+
"version wins"
|
92
|
+
changelog.reset_at(version)
|
93
|
+
else
|
94
|
+
deb_version.bump
|
95
|
+
end
|
96
|
+
|
97
|
+
LOG.debug "Adding new entry to changelog..."
|
98
|
+
changelog.add(new_version, "New release", distribution)
|
99
|
+
|
100
|
+
LOG.debug "Changelog now at #{new_version}"
|
101
|
+
puts_changelog_info
|
102
|
+
|
103
|
+
new_version
|
104
|
+
end
|
105
|
+
|
106
|
+
def puts_changelog_info
|
107
|
+
LOG.debug "OK, please update the change log, then run 'vershunt push' to"\
|
108
|
+
" push your changes for building"
|
109
|
+
end
|
110
|
+
|
111
|
+
def project_specific_push(release_name)
|
112
|
+
# Create a release commit.
|
113
|
+
commit_message = release_commit_message(release_name)
|
114
|
+
exec "git add #{changelog.fname}"
|
115
|
+
exec "git commit -m\"#{commit_message}\""
|
116
|
+
end
|
117
|
+
|
118
|
+
def prepare_for_build(branch_name, options={})
|
119
|
+
branch_is_release_branch = !! /^release-.+$/.match(branch_name)
|
120
|
+
distribution = options[:distribution] || changelog.distribution
|
121
|
+
|
122
|
+
rename_dir_for_build(branch_name, distribution)
|
123
|
+
|
124
|
+
super if defined?(super)
|
125
|
+
end
|
126
|
+
|
127
|
+
def rename_dir_for_build(branch_name, distribution)
|
128
|
+
branch_is_release_branch = !! /^release-.+$/.match(branch_name)
|
129
|
+
new_dir = Dir.chdir(@dir) do
|
130
|
+
if branch_is_release_branch
|
131
|
+
first_commit_hash, commit_message =
|
132
|
+
find_first_release_commit
|
133
|
+
|
134
|
+
if first_commit_hash.nil?
|
135
|
+
raise CLI::Exit, "Could not find a release commit on #{pathspec}"
|
136
|
+
end
|
137
|
+
|
138
|
+
clean_checkout
|
139
|
+
else
|
140
|
+
dev_version = Debian::Versions::Development.
|
141
|
+
new_from_working_directory(branch_name, latest_commit_hash)
|
142
|
+
|
143
|
+
changelog.amend(dev_version, distribution)
|
144
|
+
end
|
145
|
+
name + "-" + changelog.version.to_s
|
146
|
+
end
|
147
|
+
FileUtils.mv(@dir, new_dir)
|
148
|
+
@dir = new_dir
|
149
|
+
end
|
150
|
+
|
151
|
+
def build_opts(options={})
|
152
|
+
@sign = options[:sign]
|
153
|
+
end
|
154
|
+
|
155
|
+
def build_command(options={})
|
156
|
+
if cmd = config[:deb_build_command]
|
157
|
+
cmd
|
158
|
+
else
|
159
|
+
"dpkg-buildpackage" + (@sign ? '' : ' -us -uc')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def build_result(dir)
|
164
|
+
BuildResult.new(dir, self)
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
module MSPRelease
|
3
|
+
module Project::Gem
|
4
|
+
include MSPRelease::Exec::Helpers
|
5
|
+
|
6
|
+
class BuildResult
|
7
|
+
def initialize(dir, project)
|
8
|
+
@dir = dir
|
9
|
+
@project = project
|
10
|
+
end
|
11
|
+
|
12
|
+
def package
|
13
|
+
"#{@dir}/#{@project.gemspec_name}-#{@project.version}.gem"
|
14
|
+
end
|
15
|
+
|
16
|
+
def files
|
17
|
+
[package]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def gemspec_file
|
22
|
+
files = Dir.glob("#{@dir}/*.gemspec")
|
23
|
+
|
24
|
+
LOG.warn "Warning: more than one gemspec found" if files.count > 1
|
25
|
+
raise "Can't find gemspec" if files.count < 0
|
26
|
+
|
27
|
+
files.first
|
28
|
+
end
|
29
|
+
|
30
|
+
def gemspec_name
|
31
|
+
@gemspec_name ||= Dir.chdir(@dir) do
|
32
|
+
File.new(gemspec_file, 'r').readlines.find { |l|
|
33
|
+
l =~ /\w+\.name\s*=\s*(['"])([\w-]+)\1/
|
34
|
+
}
|
35
|
+
$2
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def name
|
40
|
+
gemspec_name
|
41
|
+
end
|
42
|
+
|
43
|
+
def next_version_for_release(options={})
|
44
|
+
tag = "release-#{version}"
|
45
|
+
check_tag = exec("git show-ref --tags #{tag}", :status => [0,1])
|
46
|
+
unless check_tag == ""
|
47
|
+
LOG.error "Tag #{tag} already exists, you must bump the version before"\
|
48
|
+
" the next release"
|
49
|
+
exit(1)
|
50
|
+
end
|
51
|
+
version
|
52
|
+
end
|
53
|
+
|
54
|
+
def prepare_for_build(branch_name, options={})
|
55
|
+
# new_dir = "#{gemspec_name}"
|
56
|
+
|
57
|
+
# FileUtils.mv(@dir, new_dir)
|
58
|
+
# @dir = new_dir
|
59
|
+
|
60
|
+
clean_checkout
|
61
|
+
|
62
|
+
super if defined?(super)
|
63
|
+
end
|
64
|
+
|
65
|
+
def build_command
|
66
|
+
"gem build #{gemspec_file}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def build_result(output_directory)
|
70
|
+
BuildResult.new(@dir, self)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Mixin module for git projects.
|
2
|
+
module MSPRelease
|
3
|
+
module Project::Git
|
4
|
+
|
5
|
+
def prepare_for_build(branch_name, options={})
|
6
|
+
branch_is_release_branch = !! /^release-.+$/.match(branch_name)
|
7
|
+
shallow_output = options[:shallow_output]
|
8
|
+
|
9
|
+
if branch_name && branch_is_release_branch
|
10
|
+
LOG.debug("Checking out latest release commit from origin/#{branch_name}#{shallow_output}")
|
11
|
+
else
|
12
|
+
LOG.debug("Checking out latest commit from origin/#{branch_name}#{shallow_output}")
|
13
|
+
end
|
14
|
+
|
15
|
+
pathspec = "origin/#{branch_name}"
|
16
|
+
if pathspec != "origin/master"
|
17
|
+
move_to(pathspec)
|
18
|
+
end
|
19
|
+
super if defined?(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def move_to(pathspec)
|
23
|
+
Dir.chdir(@dir) do
|
24
|
+
begin
|
25
|
+
exec("git show #{pathspec} --")
|
26
|
+
rescue MSPRelease::Exec::UnexpectedExitStatus => e
|
27
|
+
if /^fatal: bad revision/.match(e.stderr)
|
28
|
+
raise MSPRelease::CLI::Exit, "Git pathspec '#{pathspec}' does not exist"
|
29
|
+
else
|
30
|
+
raise
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
exec("git checkout #{pathspec}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def log_command
|
39
|
+
Dir.chdir(@dir) do
|
40
|
+
"git --no-pager log --no-color --full-index"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def oneline_pattern
|
45
|
+
/^([a-z0-9]+) (.+)$/i
|
46
|
+
end
|
47
|
+
|
48
|
+
def find_first_release_commit
|
49
|
+
all_commits = exec(log_command + " --pretty=oneline").
|
50
|
+
split("\n")
|
51
|
+
|
52
|
+
all_commits.map { |commit_line|
|
53
|
+
match = oneline_pattern.match(commit_line)
|
54
|
+
[match[1], match[2]]
|
55
|
+
}.find {|hash, message|
|
56
|
+
release_name_from_message(message)
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def latest_commit_hash
|
61
|
+
output = exec(log_command + " --pretty=oneline -1").split("\n").first
|
62
|
+
oneline_pattern.match(output)[1]
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def clean_checkout
|
67
|
+
Dir.chdir(@dir) do
|
68
|
+
first_commit_hash, commit_message = find_first_release_commit
|
69
|
+
|
70
|
+
exec "git reset --hard #{first_commit_hash}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# This kind of project uses a ruby file with a VERSION constant to be the
|
3
|
+
# authorative source for the version
|
4
|
+
#
|
5
|
+
module MSPRelease::Project::Ruby
|
6
|
+
|
7
|
+
attr_reader :ruby_version_file
|
8
|
+
|
9
|
+
def version_pattern
|
10
|
+
/VERSION *= *(['"])([0-9]+)\.([0-9]+)\.([0-9]+)\1/
|
11
|
+
end
|
12
|
+
|
13
|
+
def write_version(new_version)
|
14
|
+
lines = File.open(ruby_version_file, 'r') { |f| f.readlines }
|
15
|
+
lines = lines.map do |line|
|
16
|
+
if match = version_pattern.match(line)
|
17
|
+
line.gsub(/( *VERSION *= *)(['"]).+\2$/, "\\1\\2#{new_version.to_s}\\2")
|
18
|
+
else
|
19
|
+
line
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
File.open(ruby_version_file, 'w') { |f| f.write(lines) }
|
24
|
+
|
25
|
+
defined?(super) ?
|
26
|
+
Array(super).push(ruby_version_file) :
|
27
|
+
[ruby_version_file]
|
28
|
+
end
|
29
|
+
|
30
|
+
def version
|
31
|
+
Dir.chdir(@dir) do
|
32
|
+
File.open(ruby_version_file, 'r') do |f|
|
33
|
+
v_line = f.readlines.map {|l|version_pattern.match(l)}.compact.first
|
34
|
+
raise "Couldn't parse version from #{ruby_version_file}" unless v_line
|
35
|
+
MSPRelease::Version.new(* (2..4).map {|i|v_line[i]} )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vershunt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nick@playlouder.com
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2015-04-29 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: POpen4
|
16
|
+
prerelease: false
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.0
|
22
|
+
type: :runtime
|
23
|
+
version_requirements: *id001
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: climate
|
26
|
+
prerelease: false
|
27
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ~>
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 0.5.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id002
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rspec
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.8.0
|
42
|
+
type: :development
|
43
|
+
version_requirements: *id003
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rake
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- &id005
|
50
|
+
- ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
type: :development
|
54
|
+
version_requirements: *id004
|
55
|
+
description: Maintain versioning information in a consistent way, then build debian packages consistently.
|
56
|
+
email:
|
57
|
+
- nick@playlouder.com
|
58
|
+
executables:
|
59
|
+
- vershunt
|
60
|
+
extensions: []
|
61
|
+
|
62
|
+
extra_rdoc_files: []
|
63
|
+
|
64
|
+
files:
|
65
|
+
- bin/vershunt
|
66
|
+
- lib/msp_release.rb
|
67
|
+
- lib/msp_release/build.rb
|
68
|
+
- lib/msp_release/cli.rb
|
69
|
+
- lib/msp_release/cli/branch.rb
|
70
|
+
- lib/msp_release/cli/build.rb
|
71
|
+
- lib/msp_release/cli/bump.rb
|
72
|
+
- lib/msp_release/cli/checkout.rb
|
73
|
+
- lib/msp_release/cli/distrib.rb
|
74
|
+
- lib/msp_release/cli/help.rb
|
75
|
+
- lib/msp_release/cli/new.rb
|
76
|
+
- lib/msp_release/cli/push.rb
|
77
|
+
- lib/msp_release/cli/reset.rb
|
78
|
+
- lib/msp_release/cli/status.rb
|
79
|
+
- lib/msp_release/debian.rb
|
80
|
+
- lib/msp_release/exec.rb
|
81
|
+
- lib/msp_release/git.rb
|
82
|
+
- lib/msp_release/log.rb
|
83
|
+
- lib/msp_release/make_branch.rb
|
84
|
+
- lib/msp_release/options.rb
|
85
|
+
- lib/msp_release/project.rb
|
86
|
+
- lib/msp_release/project/base.rb
|
87
|
+
- lib/msp_release/project/debian.rb
|
88
|
+
- lib/msp_release/project/gem.rb
|
89
|
+
- lib/msp_release/project/git.rb
|
90
|
+
- lib/msp_release/project/ruby.rb
|
91
|
+
- lib/msp_release/version.rb
|
92
|
+
homepage:
|
93
|
+
licenses: []
|
94
|
+
|
95
|
+
metadata: {}
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- *id005
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- *id005
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.6
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Repeatable build system tool
|
115
|
+
test_files: []
|
116
|
+
|