-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitPusher.lua
More file actions
30 lines (27 loc) · 801 Bytes
/
Copy pathgitPusher.lua
File metadata and controls
30 lines (27 loc) · 801 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
local function commander(argToExcute)
local result = io.popen(argToExcute)
local strInfo = result:read("*all")
return strInfo
end
function tryTillSucceed(arg,tryTimes)
tryTimes = tryTimes or 1000
for i = 1,tryTimes,1 do
print('argument is: ',arg)
local res = commander(arg)
if res ~= '' then
print('Conduction succeeded!')
break
end
end
return
end
local commitInfo = '\"auto commit at ostime(' .. string.sub(tostring(os.time()),5) .. ') via gitPusher\"'
local addCmd = 'git add .'
local commitCmd = 'git commit -m ' .. commitInfo
local pushCmd = 'git push -u origin main'
local pullCmd = 'git pull'
tryTillSucceed(pullCmd)
os.execute(addCmd)
os.execute(commitCmd)
tryTillSucceed(pushCmd)
tryTillSucceed(pullCmd)