summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-13 23:01:50 +0800
committerruki <[email protected]>2022-04-13 23:01:50 +0800
commit9e4be5c8d422a2f089e15679865b217d0958b98c (patch)
tree0f5f9812e3c02ae2b76002e3d2f4b8873f04538e
parent260b86994e5e8e75d2f1df1667f5369f47c2bbe4 (diff)
improve git.branch
-rw-r--r--xmake/modules/devel/git/branch.lua15
1 files changed, 4 insertions, 11 deletions
diff --git a/xmake/modules/devel/git/branch.lua b/xmake/modules/devel/git/branch.lua
index 391ffd27e..b2a8602cb 100644
--- a/xmake/modules/devel/git/branch.lua
+++ b/xmake/modules/devel/git/branch.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("lib.detect.find_tool")
+import("branches", {alias = "git_branches"})
-- get current branch
--
@@ -37,16 +38,8 @@ import("lib.detect.find_tool")
--
function main(opt)
opt = opt or {}
- local git = assert(find_tool("git"), "git not found!")
- local argv = {"branch"}
- if not option.get("verbose") then
- table.insert(argv, "-q")
- end
- local branch = os.iorunv(git.program, argv, {curdir = opt.repodir})
- if branch then
- branch = branch:trim()
- if #branch > 0 then
- return branch
- end
+ local branches = git_branches(opt.repodir)
+ if branches and #branches > 0 then
+ return branches[1]
end
end