forked from LuaDist/lua-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.lua
50 lines (37 loc) · 893 Bytes
/
test.lua
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
package.path = package.path .. ';lua/?.lua'
package.cpath = package.cpath .. ';b/?.so'
require 'git'
local r = git.repo.open('.')
local c = r:head()
print('Commit', c.id)
print(c.author)
print(c.committer)
print(c.message)
print()
c:checkout('tst')
local parent = c.parents[1]
local pc = r:commit(parent)
print('Commit', pc.id)
print(pc.author)
print(pc.committer)
print(pc.message)
print()
local tree = pc:tree()
tree:walk(function(entry, entry_path, type)
print(type, entry_path)
end)
print()
print(tree['git.lua']:content())
-- find the initial commit
while #c.parents > 0 do
c = r:commit(c.parents[1])
end
print(c.message)
c:tree():walk(function(entry, entry_path, type)
print(type, entry_path)
end)
os.execute('rm -rf tst2')
os.execute('mkdir tst2')
os.execute('cd tst2 && git init')
r = git.repo.open('tst2')
git.protocol.fetch('git://github.com/mkottman/lua-git.git', r)