forked from matthewfallshaw/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsake
38 lines (36 loc) · 1.19 KB
/
sake
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
desc 'Add an external project as a sub-tree'
task 'git:subtree:add' do
require("readline")
name = (print("Remote Name? ")
Readline.readline.chomp)
url = (print("Git Repo Url? ")
Readline.readline.chomp)
`git remote add #{name} #{url}`
`git config remote.#{name}.fetch refs/heads/*:refs/remotes/#{name}/*`
`git config --add remote.#{name}.fetch refs/tags/*:refs/remotes/#{name}/tags/*`
`git config remote.#{name}.tagopt --no-tags`
`git fetch #{name}`
end
desc 'Merge a sub-tree into your project'
task 'git:subtree:merge' do
require("readline")
name = (print("Remote Name? ")
Readline.readline.chomp)
branch = (print("Remote Branch? ")
Readline.readline.chomp)
dest = (print("Destination? ")
Readline.readline.chomp)
`git merge -s ours --no-commit #{name}/#{branch}`
`git read-tree --prefix=#{dest} -u #{name}/#{branch}`
`git commit -m \"Merge branch '#{branch}' of #{name}\"`
end
desc 'Pull (fetch & merge) into an existing sub-tree'
task 'git:subtree:pull' do
require("readline")
name = (print("Remote Name? ")
Readline.readline.chomp)
branch = (print("Remote Branch? ")
Readline.readline.chomp)
`git pull -s subtree #{name} #{branch}`
end
# vi:filetype=ruby: