Skip to content
Newer
Older
100644 170 lines (138 sloc) 3.62 KB
04ff458 @eschulte added some git rake tasks
eschulte authored
1 require 'readline'
2 require 'find'
2d5c35e @technomancy added a rake file for tests
authored
3
466aaa9 @eschulte updated documentation and rake tasks
eschulte authored
4 MYDIR = File.dirname(__FILE__)
5 DOCDIR = "#{MYDIR}/doc"
13910c5 @eschulte code cleanup, adding tests
eschulte authored
6 TESTDIR = "#{MYDIR}/test"
7
8 namespace "test" do
9
10 desc "Run tests using `emacs-snapshot'"
11 task :snapshot do
12 system "emacs-snapshot -Q -l #{TESTDIR}/init.el"
13 end
14
15 desc "Run tests using `emacs-22'"
16 task :twenty_two do
17 system "emacs22 -Q -l #{TESTDIR}/init.el"
18 end
19
20 desc "Run tests using `emacs'"
21 task :emacs do
22 system "emacs -Q -l #{TESTDIR}/init.el"
23 end
24
25 end
466aaa9 @eschulte updated documentation and rake tasks
eschulte authored
26
27 namespace "doc" do
28
29 desc "Compile the html documentation"
30 task :make_html do
31 system "makeinfo --html #{DOCDIR}/rinari.texi"
32 end
33
34 desc "Compile info documentation"
35 task :make_info do
36 system "makeinfo #{DOCDIR}/rinari.texi"
37 end
38
39 desc "Install info documentation"
40 task :install_info => :make_info do
41 system "sudo install-info #{DOCDIR}/rinari.info"
42 end
43
44 desc "Remove compiled documentation"
45 task :clean do
46 system "rm -rf #{DOCDIR}/rinari" if FileTest.exists? "#{DOCDIR}/rinari"
47 system "rm #{DOCDIR}/rinari.info" if FileTest.exists? "#{DOCDIR}/rinari.info"
48 end
49
50 end
51
b02f6c6 @technomancy Add `rinari-minor-mode-hook' for customization. Make some variables b…
authored
52 task :default => :'test:emacs'
04ff458 @eschulte added some git rake tasks
eschulte authored
53
54 # some git tasks taken from the rubinius
55 def git_branch
56 `git branch | grep "*"`.strip[2..-1]
57 end
58
59 def compare_git_ver
60 m = /git version (\d+).(\d+).(\d+)/.match(`git version`.strip)
61 return true if m[1].to_i > 1
62 return false if m[1].to_i < 1
63 return true if m[2].to_i > 5
64 return false if m[2].to_i < 5
65 return true if m[3].to_i >= 3
66 return false
67 end
68
69 def check_git_ver
70 raise "Invalid git version, use at least 1.5.3" unless compare_git_ver
71 end
72
73 namespace :git do
74
75 desc "Show the current status of the checkout"
76 task :status do
77 system "git status"
78 end
79
80 desc "Create a new topic branch"
81 task :topic do
82 total = `git branch`.scan("quick").size
83 if total == 0
84 default = "quick"
85 else
86 default = "quick#{total + 1}"
87 end
88 name = Readline.readline "Topic name (default #{default}): "
89 if name.strip.empty?
90 name = default
91 end
92 sh "git checkout -b #{name}"
93 end
94
95 desc "Push all changes to the repository"
96 task :push => :update do
97 branch = git_branch()
98 if branch != "master"
99 `git diff-files --quiet`
100 if $?.exitstatus == 1
101 puts "You have outstanding changes. Please commit them first."
102 exit 1
103 end
104
105 puts "* Merging topic '#{branch}' back into master..."
106 `git checkout master`
107 sh "git merge #{branch}"
108 switch = true
109 else
110 switch = false
111 end
112
113 puts "* Pushing changes..."
114 sh "git push"
115
116 if switch
117 puts "* Switching back to #{branch}..."
118 `git checkout #{branch}`
119 end
120 end
121
122 desc "Pull new commits from the repository"
123 task :update do
124 check_git_ver
125 `git diff-files --quiet`
126 if $?.exitstatus == 1
127 stash = true
128 clear = `git stash list`.scan("\n").size == 0
129 puts "* Saving changes..."
130 `git stash save`
131 else
132 stash = false
133 end
134
135 branch = git_branch()
136 if branch != "master"
137 switch = true
138 `git checkout master`
139 puts "* Switching back to master..."
140 else
141 switch = false
142 end
143
144 puts "* Pulling in new commits..."
145 sh "git fetch"
146 sh "git rebase origin"
147
148 if switch
149 puts "* Porting changes into #{branch}..."
150 `git checkout #{branch}`
151 sh "git rebase master"
152 end
153
154 if stash
155 puts "* Applying changes..."
156 sh "git stash apply"
157 `git stash clear` if clear
158 end
159 end
160
161 task :pull => :update
162
163 desc "remove all .git folders from the directory"
164 task :clean do
165 Find.find("./"){|f| FileUtils.rm_rf(f) if f =~ /\.git.*/}
166 end
167
168 end
169 # end some git tasks taken from the rubinius
Something went wrong with that request. Please try again.