@@ -4,6 +4,7 @@ local micro = import("micro")
44local buffer = import (" micro/buffer" )
55local config = import (" micro/config" )
66local shell = import (" micro/shell" )
7+ local filepath = import (" filepath" )
78local humanize = import (" humanize" )
89local strings = import (" strings" )
910
@@ -34,24 +35,23 @@ function size(b)
3435 return humanize .Bytes (b :Size ())
3536end
3637
37- function branch ( b )
38+ local function parseRevision ( b , opt )
3839 if b .Type .Kind ~= buffer .BTInfo then
39- local branch , err = shell .ExecCommand (" git" , " rev-parse" , " --abbrev-ref" , " HEAD" )
40+ local dir = filepath .Dir (b .Path )
41+ local str , err = shell .ExecCommand (" git" , " -C" , dir , " rev-parse" , opt , " HEAD" )
4042 if err == nil then
41- return strings .TrimSpace (branch )
43+ return strings .TrimSpace (str )
4244 end
43- return " "
4445 end
46+ return " "
47+ end
48+
49+ function branch (b )
50+ return parseRevision (b , " --abbrev-ref" )
4551end
4652
4753function hash (b )
48- if b .Type .Kind ~= 5 then
49- local hash , err = shell .ExecCommand (" git" , " rev-parse" , " --short" , " HEAD" )
50- if err == nil then
51- return strings .TrimSpace (hash )
52- end
53- return " "
54- end
54+ return parseRevision (b , " --short" )
5555end
5656
5757function paste (b )
0 commit comments