path:
/listAllRefs.nim
747 B | plain
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 import os
import nimgit
if paramCount() == 0:
echo "No git-repo given."
quit(QuitFailure)
discard git_libgit2_init()
try:
let gitRepository = openGitRepository(paramStr(1))
let gitRefNames = gitRepository.getGitReferenceNames()
for gitRefName in gitRefNames:
let gitReference = gitRepository.lookupGitReference(gitRefName)
case gitReference.getType():
of referenceDirect:
echo gitRefName & ": " & $gitReference.getTarget()
of referenceSymbolic:
echo gitRefName & " => " & gitReference.getSymbolicTarget() & ": " & $gitReference.getTarget()
free(gitReference)
free(gitRepository)
except:
echo "Error:\n", getCurrentExceptionMsg()