-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.rb
42 lines (40 loc) · 1.01 KB
/
git.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -- encoding: utf-8 --
class Rim
# Git push commands (default: <tt>['--tags origin master']</tt>)
attr_accessor :git_push_commands
end
Rim.defaults do
git_push_commands ['--tags origin master']
end
Rim.after_setup do
if File.exist?('.git') && File.directory?('.git')
tag_name = "v#{version}"
namespace :git do
desc "Create git tag #{tag_name}"
tag_task = task :tag do
cmd = "git tag #{tag_name}"
sh cmd
end
desc 'Check if git tree is clean'
task :check do
res = `git status --porcelain`
unless res.empty?
fail 'Git tree is not clean'
end
end
desc 'Push master to git remotes'
task :push => :check do
git_push_commands.each do |cmd|
sh "git push #{cmd}"
end
end
end
if feature_loaded? 'rim/gem'
task 'gem:push' => 'git:check'
task 'git:tag' => 'gem:push'
end
if feature_loaded? 'rim/release'
task :release => %w(git:check git:tag)
end
end
end