This repository was archived by the owner on Dec 10, 2021. It is now read-only.
forked from pivotal/workstation-setup
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgit.rb
More file actions
executable file
·41 lines (35 loc) · 1.39 KB
/
git.rb
File metadata and controls
executable file
·41 lines (35 loc) · 1.39 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
#!/usr/bin/env ruby
require_relative './base.rb'
class ConfigureGitTracker < TrackerConfigurationBase
def run
# Add Tracker .git-authors
FileUtils.copy("#{repo_root}/files/tracker/.git-authors", "#{home}/.git-authors")
# Do the Tracker-specific Git configuration
set_git_config('pull.rebase', 'preserve')
set_git_config('push.default', 'current')
set_git_config('user.email', 'labs-tracker-team@pivotal.io')
set_git_config('user.name', 'Pivotal Tracker')
process_without_output('git config --global --unset transfer.fsckobjects', expected_exit_status: [0, 5])
set_git_config('fsck.zeroPaddedFilemode', 'ignore')
# Load in the known hosts (note we cannot copy from files/tracker/.ssh
# because of permissions and we don't want to override)
FileUtils.mkdir_p("#{home}/.ssh", mode: 0700)
known_hosts = "#{home}/.ssh/known_hosts"
FileUtils.touch(known_hosts)
FileUtils.chmod(0600, known_hosts)
File.readlines("#{repo_root}/files/tracker/.ssh/known_hosts").each do |line|
host_matched = File.readlines(known_hosts).any? do |known_host|
known_host == line
end
unless host_matched
File.open(known_hosts, 'a') do |file|
file.puts(line)
end
end
end
end
def set_git_config(key, value)
process_without_output("git config --global '#{key}' '#{value}'")
end
end
ConfigureGitTracker.new.run