-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.rb
More file actions
38 lines (31 loc) · 806 Bytes
/
project.rb
File metadata and controls
38 lines (31 loc) · 806 Bytes
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
# Recursively climbs directory tree until root looking for SpreadDir
# This is similar to the behavior of '.git'
def detectSpread(dir)
possible = "#{dir}/#{SpreadDir}"
if File.directory?(possible)
return possible
end
parent = File.expand_path("..", dir)
if dir == parent
return false
end
detectSpread parent
end
def setupProject(wd=Dir.pwd)
dir = "#{wd}/#{SpreadDir}"
# check if directory already exists
if File.directory?(dir)
puts "#{dir} already exists"
exit 1
end
# create directory
Dir.mkdir(dir)
# setup git
gitDir = "#{dir}/git"
`git init --bare #{gitDir}`
if !$?.success?
puts "failed to setup project"
exit 1
end
puts "Created empty Spread repository at #{dir}"
end