-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.lua
More file actions
98 lines (77 loc) · 2.26 KB
/
convert.lua
File metadata and controls
98 lines (77 loc) · 2.26 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
-- see if the file exists
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
end
-- get all lines from a file, returns an empty
-- list/table if the file does not exist
function lines_from(file)
if not file_exists(file) then
return {}
end
a_lines = {}
for line in io.lines(file) do
a_lines[#a_lines + 1] = line
end
return a_lines
end
-- uses the functions above
local file = 'branch.log'
local lines = lines_from(file)
local log2 = 'new_log.log'
fnew = io.open(log2,"w")
-- print all line numbers and their contents
for num,txt in pairs(lines) do
not_matched = true
--get first four letters to check
s_sub = string.sub(txt,1, 4)
--check for nonsense
if string.match(s_sub,"[-]") then
if num == 1 then
a_lines[num] = ""
print("")
fnew:write("")
not_matched = false
else
a_lines[num] = ""
print("\n")
fnew:write("\n")
not_matched = false
end
end
--find the revisions
if string.match(s_sub,"r%d+")and not_matched then
rev = string.match(txt,"r(%d+)")
name = string.match(txt,"|.-|")
name = string.sub(name,3,#name-2)
y,m,d,h,mins,s = string.match(txt,"| (2...)%D(%d%d)%D(%d%d).(%d%d)%D(%d%d)%D(%d%d).-|")
--print(rev.." "..name.." "..y.."."..m.."."..d.." "..h..":"..mins..":"..s)
unix_t = os.time({year=y,month=m,day=d,hour=h,min=mins,sec=s,true})
--git log --reverse --numstat --pretty=format:"author: %an|%ae%ndate: %ct%n" --name-status --no-merges > log.txt
print("info: "..name.."|"..name.."@xyz.com|"..unix_t.."2")
fnew:write("info: "..name.."|"..name.."@xyz.com|"..unix_t.."\n")
not_matched = false
end
--find modified /added/deleted stuff
if string.match(s_sub," [ADM]")and not_matched then
if string.len(txt) >7 then
txt = string.match(txt," ([ADM].+)")
ps = string.find(txt,"/")
--txt = string.gsub(txt," \"," ")
--print(pos)
if pos == 3 then
txt = string.gsub(txt," /"," " )
end
print(txt)
fnew:write(txt.."\n")
not_matched = false
else
txt = ""
print(txt)
fnew:write(txt.."")
not_matched = false
end
end
end
io.close(fnew)