diff options
| author | ruki <[email protected]> | 2024-01-11 00:43:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-11 00:43:24 +0800 |
| commit | 8db99f3c25f137b46444e4e4b12d874d3d2f8978 (patch) | |
| tree | 80397f5230af0814fd9a716ab518f3b9d674e9a8 /xmake/modules/devel/git/branch.lua | |
| parent | d17d638df1f626f02a60ca6f2c284c217a63fa74 (diff) | |
fix git.branch
Diffstat (limited to 'xmake/modules/devel/git/branch.lua')
| -rw-r--r-- | xmake/modules/devel/git/branch.lua | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/xmake/modules/devel/git/branch.lua b/xmake/modules/devel/git/branch.lua index b2a8602cb..08f1f7bf0 100644 --- a/xmake/modules/devel/git/branch.lua +++ b/xmake/modules/devel/git/branch.lua @@ -21,7 +21,7 @@ -- imports import("core.base.option") import("lib.detect.find_tool") -import("branches", {alias = "git_branches"}) +import("net.proxy") -- get current branch -- @@ -38,8 +38,29 @@ import("branches", {alias = "git_branches"}) -- function main(opt) opt = opt or {} - local branches = git_branches(opt.repodir) - if branches and #branches > 0 then - return branches[1] + + -- find git + local git = assert(find_tool("git"), "git not found!") + + -- init arguments + local argv = {"branch", "--show-current"} + + -- trace + if option.get("verbose") then + print("%s %s", git.program, os.args(argv)) + end + + -- use proxy? + local envs + local proxy_conf = proxy.config(url) + if proxy_conf then + envs = {ALL_PROXY = proxy_conf} + end + + -- get current branch + local branch = os.iorunv(git.program, argv, {envs = envs, curdir = opt.repodir}) + if branch then + branch = branch:trim() end + return branch end |
