forked from geoffgarside/Git.framework
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
141 lines (130 loc) · 4.01 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
desc "Default task (test)"
task :default => [:test]
desc "Builds the release version of the framework"
task :build => ['build:release']
namespace :build do
desc "Builds the debug version of the framework"
task :debug do
sh 'xcodebuild -target Git -configuration Debug'
end
desc "Builds the release version of the framework"
task :release do
sh 'xcodebuild -target Git -configuration Release'
end
end
namespace :bridgesupport do
desc 'Generate the BridgeSupport MetaData'
task :generate => ['build:release'] do
sh 'gen_bridge_metadata -f ./build/Release/Git.framework -o ./Resource/BridgeSupport/Git.bridgesupport --64-bit'
end
end
desc "Runs the test suite for the framework (Requires MacRuby)"
task :test do
sh 'xcodebuild -target Tests -configuration Debug'
end
desc "Generates the documentation for the framework (Requires Doxygen)"
task :documentation => ['documentation:release']
namespace :documentation do
desc "Generates the debug version of the documentation for the framework (Requires Doxygen)"
task :debug do
sh 'xcodebuild -target Documentation -configuration Debug'
end
desc "Generates the release version of the documentation for the framework (Requires Doxygen)"
task :release do
sh 'xcodebuild -target Documentation -configuration Release'
end
task :clean do
sh 'rm -r Documentation/{html,tmp,xml}'
end
file 'Documentation/html/index.html' => 'documentation:release'
task :open => 'Documentation/html/index.html' do
sh 'open Documentation/html/index.html'
end
end
namespace :website do
desc "Update the website data from the generated documentation"
task :update => [:documentation] do
sh 'rsync -tav --delete --exclude .git Documentation/html/ Website/'
end
desc "Commit the updated website data"
task :commit => :update do
Dir.chdir('Website') do
sh 'git commit -a -m "Update Website"'
end
sh 'git commit Website -m "Update Website"'
end
desc "Push the updated website to the gh-pages branch"
task :push do
Dir.chdir('Website') do
sh 'git push origin gh-pages'
end
end
end
def check_for_tabs_in(srcfile)
line_number = 0
File.readlines(srcfile).each do |line|
line_number += 1
if line.index("\t")
puts "#{srcfile}:#{line_number}\t#{line}"
end
end
end
namespace :check_tabs do
desc "Checks staged files for tab characters"
task :staged do
puts "Checking for tab characters in staged files..."
`git diff --cached --name-only`.split("\n").each do |srcfile|
check_for_tabs_in srcfile
end
end
desc "Checks source files for tab charactesr"
task :source do
puts "Checking for tab characters in Source/ files..."
Dir.glob("Source/**/*.[hm]").each do |srcfile|
check_for_tabs_in srcfile
end
end
desc "Installs the git hook to check staged files for tabs before commit"
task :install_hook do
hook_file = ".git/hooks/pre-commit"
pre_commit = <<EOF
#!/usr/bin/env ruby
found = []
`git diff --staged --name-only`.split("\\n").each do |srcfile|
next unless File.file?(srcfile)
next if srcfile =~ /project\.pbxproj$/
next if srcfile =~ /\.dmg$/
next if srcfile =~ /^\.git/
next if srcfile =~ /\.plist$/
line_number = 0
File.readlines(srcfile).each do |line|
line_number += 1
if line.index("\\t")
found << "\#{srcfile}:\#{line_number}\\t\#{line}"
end
end
end
unless found.empty?
puts "Error: Attempt to add file with tab indentation"
puts ""
puts "This project uses spaces rather than tabs for indendation,"
puts "please fix the lines of the following files and then re-add"
puts "the files to the index and re-commit.\\n\\n"
puts found.join("\\n")
exit 1
end
exit 0
EOF
if File.exists?(hook_file)
puts "You already have a pre-commit hook, either remove it or add the following"
puts "----- Add to #{hook_file} -----"
puts pre_commit
puts "-------------------------------"
else
File.open(hook_file, "w") do |f|
f.write(pre_commit)
end
FileUtils.chmod(0755, hook_file)
end
end
end