forked from technomancy/rinari
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
169 lines (138 loc) · 3.62 KB
/
Rakefile
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
require 'readline'
require 'find'
MYDIR = File.dirname(__FILE__)
DOCDIR = "#{MYDIR}/doc"
TESTDIR = "#{MYDIR}/test"
namespace "test" do
desc "Run tests using `emacs-snapshot'"
task :snapshot do
system "emacs-snapshot -Q -l #{TESTDIR}/init.el"
end
desc "Run tests using `emacs-22'"
task :twenty_two do
system "emacs22 -Q -l #{TESTDIR}/init.el"
end
desc "Run tests using `emacs'"
task :emacs do
system "emacs -Q -l #{TESTDIR}/init.el"
end
end
namespace "doc" do
desc "Compile the html documentation"
task :make_html do
system "makeinfo --html #{DOCDIR}/rinari.texi"
end
desc "Compile info documentation"
task :make_info do
system "makeinfo #{DOCDIR}/rinari.texi"
end
desc "Install info documentation"
task :install_info => :make_info do
system "sudo install-info #{DOCDIR}/rinari.info"
end
desc "Remove compiled documentation"
task :clean do
system "rm -rf #{DOCDIR}/rinari" if FileTest.exists? "#{DOCDIR}/rinari"
system "rm #{DOCDIR}/rinari.info" if FileTest.exists? "#{DOCDIR}/rinari.info"
end
end
task :default => :'test:emacs'
# some git tasks taken from the rubinius
def git_branch
`git branch | grep "*"`.strip[2..-1]
end
def compare_git_ver
m = /git version (\d+).(\d+).(\d+)/.match(`git version`.strip)
return true if m[1].to_i > 1
return false if m[1].to_i < 1
return true if m[2].to_i > 5
return false if m[2].to_i < 5
return true if m[3].to_i >= 3
return false
end
def check_git_ver
raise "Invalid git version, use at least 1.5.3" unless compare_git_ver
end
namespace :git do
desc "Show the current status of the checkout"
task :status do
system "git status"
end
desc "Create a new topic branch"
task :topic do
total = `git branch`.scan("quick").size
if total == 0
default = "quick"
else
default = "quick#{total + 1}"
end
name = Readline.readline "Topic name (default #{default}): "
if name.strip.empty?
name = default
end
sh "git checkout -b #{name}"
end
desc "Push all changes to the repository"
task :push => :update do
branch = git_branch()
if branch != "master"
`git diff-files --quiet`
if $?.exitstatus == 1
puts "You have outstanding changes. Please commit them first."
exit 1
end
puts "* Merging topic '#{branch}' back into master..."
`git checkout master`
sh "git merge #{branch}"
switch = true
else
switch = false
end
puts "* Pushing changes..."
sh "git push"
if switch
puts "* Switching back to #{branch}..."
`git checkout #{branch}`
end
end
desc "Pull new commits from the repository"
task :update do
check_git_ver
`git diff-files --quiet`
if $?.exitstatus == 1
stash = true
clear = `git stash list`.scan("\n").size == 0
puts "* Saving changes..."
`git stash save`
else
stash = false
end
branch = git_branch()
if branch != "master"
switch = true
`git checkout master`
puts "* Switching back to master..."
else
switch = false
end
puts "* Pulling in new commits..."
sh "git fetch"
sh "git rebase origin"
if switch
puts "* Porting changes into #{branch}..."
`git checkout #{branch}`
sh "git rebase master"
end
if stash
puts "* Applying changes..."
sh "git stash apply"
`git stash clear` if clear
end
end
task :pull => :update
desc "remove all .git folders from the directory"
task :clean do
Find.find("./"){|f| FileUtils.rm_rf(f) if f =~ /\.git.*/}
end
end
# end some git tasks taken from the rubinius