This repository was archived by the owner on May 8, 2018. It is now read-only.
forked from ilozka/git-commit-notifier
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRakefile
More file actions
58 lines (46 loc) · 2.24 KB
/
Rakefile
File metadata and controls
58 lines (46 loc) · 2.24 KB
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
require 'rake'
require 'rake/testtask'
require 'rubygems'
require 'diff/lcs'
require 'yaml'
task :default => [:test]
desc "Run tests"
task :test do |test|
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*.rb']
t.verbose = true
end
end
desc "Install Git Commit Notifier for the first time"
task :install do |install|
puts "Full path to yor project repository (eg. /home/git/repositories/myproject.git):"
project_path = STDIN.gets.strip
hooks_dir = "#{project_path}/hooks"
raise 'hooks directory not found for the specified project - cannot continue' unless File.exist?(hooks_dir)
hooks_dir += '/' unless hooks_dir[-1,-1] == '/'
install_path = '/usr/local/share'
install_script_files(install_path)
execute_cmd "mv #{hooks_dir}post-receive #{hooks_dir}post-receive.old.#{Time.now.to_i}" if File.exist?("#{hooks_dir}post-receive")
execute_cmd "cp post-receive #{hooks_dir}"
execute_cmd "chmod a+x #{hooks_dir}post-receive"
Dir.chdir(project_path)
puts "Warning: no Git mailing list setting exists for your project. Please go to your project directory and set it with the git config hooks.mailinglist=you@yourdomain.com command or specify 'recipient_address' in the #{config_file} file else no emails can be sent out.\n\n" if `git config hooks.mailinglist`.empty?
puts "Warning: no Git email prefix setting exists for your project. Please go to your project directory and set it with the git config hooks.emailprefix=your_project_name or specify 'application_name' in the #{config_file} file\n\n" if `git config hooks.emailprefix`.empty?
puts "Emails are sent by default via local sendmail. To change this, update #{config_file}"
puts "Installation successful. Update config.yml to setup notification for more projects."
end
desc "Update already installed Git Commit Notifier"
task :update do |update|
install_script_files('/usr/local/share')
puts "Update successful."
end
def install_script_files(install_path)
execute_cmd "cp -r git_commit_notifier/ #{install_path}"
execute_cmd "cp README.rdoc #{install_path}/git_commit_notifier"
execute_cmd "cp LICENSE #{install_path}/git_commit_notifier"
end
def execute_cmd(cmd)
`#{cmd}`
raise 'error occurred - installation aborted' if $?.exitstatus != 0
end