I have the following code:
branch, err := gR.LookupBranch(branchName, git.BranchLocal)
if err != nil {
return err
}
defer branch.Free()
commit, err := gR.LookupCommit(branch.Target())
if err != nil {
return err
}
defer commit.Free()
tree, err := gR.LookupTree(commit.TreeId())
if err != nil {
return err
}
defer tree.Free()
err = tree.Walk(func(td string, te *git.TreeEntry) int {
if te.Type == git.ObjectBlob {
fmt.Println(te.Name)
}
return 0
})
This recursively prints out all the files in the repository. For example, if we had the following files in our repo:
test_file.txt
test_file_2.txt
test_folder/test_subfile_1.txt
test_folder/test_subfolder/test_subfile_2.txt
Then it would print:
test_file.txt
test_file2.txt
test_subfile_1.txt
test_subfile_2.txt
Instead, my aim is to print:
test_file.txt
test_file_2.txt
test_folder
But then also be able to choose to start the walk from inside the folder, so be able to print:
test_subfile_1.txt
test_subfolder
How can I achieve this? (The aim is to lazy load a directory structure into a web client i.e. to allow the web client to load contents of folders when the user opens them - also note this is a bare repo)