Repository navigation
Expand file tree
/
Copy pathgit.omi
More file actions
81 lines (80 loc) · 2.06 KB
/
Copy pathgit.omi
File metadata and controls
81 lines (80 loc) · 2.06 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--
local insert, remove = table.insert, table.remove;
--
if not make.utils.which("git"..make.utils.choose(WINDOWS, ".exe", "")) then
warning("'git' not found in path.");
return;
end;
--
git = make.newTool();
--
local dirlist = {};
function git:action_checkout(...)
local par = self:checkParam(...);
local dir, url, branch;
if par.odir then
dir = par.odir;
par.odir = nil;
else
dir = par[1];
remove(par, 1);
end;
if dirlist[dir] then return; end; -- alredy checked out
if par.url and not par.src then
par.src = par.url;
par.url = nil;
end;
if par.src then
url = par.src;
par.src = nil;
else
url = par[1];
remove(par, 1);
end;
if par.branch then
branch = par.branch;
par.branch = nil;
else
branch = par[1];
remove(par, 1);
end;
if type(dir) ~= "string" then quitMF("no valid odir given."); end;
local fnx = dir..".git";
if not make.options.forcegitscheckout then
if type(url) ~= "string" then quitMF("no valid url given."); end;
if make.utils.exists(dir) and not make.utils.isDir(dir) then
make.quitMF("cant overwrite '%s'.", dir);
end;
local filetime_delta = os.time() - make.utils.filetime(fnx);
-- checkout at least 24 hours old ?
if filetime_delta < 86400 and make.utils.exists(dir) then return; end;
end;
local cmd = "git checkout " .. url .. " " .. dir;
if make.options.verbose then
print(cmd);
elseif not make.options.quiet then
print("GIT-CO "..url);
end;
if not make.utils.execute(cmd, make.options.quiet) then
quitMF("git checkout failed.");
else
dirlist[dir] = true;
local f = io.open(fnx,"w+");
if f then
f:write(("%s checked out with:\n%s ."):format(dir, cmd));
f:close();
end;
end;
end;
git:add_action("checkout");
--
-- add toolchain specific commandline switches
local cmdl = require "Cmdl";
insert(cmdl.argsd,
{ tag = "forcegitscheckout",
cmd = {'-gfc', "--git-force-checkout"},
descr = "force all git checkouts. (default: every 24 hours)",
blockedby = {"printhelp", "printversion"},
}
);
--