only pull and add

This commit is contained in:
Paul Liverman III 2018-03-01 19:42:36 -08:00
parent 380708bae6
commit 4e92faf3ab
3 changed files with 9 additions and 12 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
*.lua
!push.lua
!pull.lua
!add.lua

View File

@ -28,19 +28,18 @@ for line in list:gmatch("[^\n]+") do
end
for _index_0 = 1, #config do
local item = config[_index_0]
if item.remote and item.remote.push then
if "boolean" == type(item.remote.push) then
item.remote.push = item.remote.fetch
end
if item.remote and item.remote.fetch then
if not (item.remote.branch) then
item.remote.branch = "master"
end
if item.remote.name then
if not (remotes[item.remote.name]) then
execute("git remote add -f " .. tostring(item.remote.name) .. " " .. tostring(item.remote.fetch))
if item.remote.push and not ("boolean" == type(item.remote.push)) then
execute("git remote set-url --push " .. tostring(item.remote.name) .. " " .. tostring(item.remote.push))
end
end
execute("git subtree push --prefix " .. tostring(item.path:gsub("%.", "/")) .. " " .. tostring(item.remote.push) .. " " .. tostring(item.remote.branch))
end
execute("git subtree add --prefix " .. tostring(item.path:gsub("%.", "/")) .. " " .. tostring(item.remote.fetch) .. " " .. tostring(item.remote.branch) .. " --squash")
end
end

View File

@ -24,16 +24,15 @@ for line in list\gmatch "[^\n]+"
remotes[line] = true
for item in *config
if item.remote and item.remote.push -- if configured to push
if "boolean" == type item.remote.push
item.remote.push = item.remote.fetch
if item.remote and item.remote.fetch -- if configured to pull
unless item.remote.branch
item.remote.branch = "master"
if item.remote.name -- if we want a named remote
unless remotes[item.remote.name] -- add it if needed
execute "git remote add -f #{item.remote.name} #{item.remote.fetch}"
if item.remote.push and not ("boolean" == type item.remote.push)
execute "git remote set-url --push #{item.remote.name} #{item.remote.push}"
-- we actually ignore names with in-script usage..
execute "git subtree push --prefix #{item.path\gsub "%.", "/"} #{item.remote.push} #{item.remote.branch}"
execute "git subtree add --prefix #{item.path\gsub "%.", "/"} #{item.remote.fetch} #{item.remote.branch} --squash"