From ab2c5e2a3b29bb63b23a7fa59c3f6d56cc56c47c Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 29 Aug 2021 21:56:52 +0800 Subject: improve git ops --- xmake/modules/devel/git/pull.lua | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'xmake/modules/devel/git/pull.lua') diff --git a/xmake/modules/devel/git/pull.lua b/xmake/modules/devel/git/pull.lua index 9970f8dbc..412e6e757 100644 --- a/xmake/modules/devel/git/pull.lua +++ b/xmake/modules/devel/git/pull.lua @@ -58,18 +58,12 @@ function main(opt) table.insert(argv, "--tags") end - -- enter repository directory - local oldir = nil - if opt.repodir then - oldir = os.cd(opt.repodir) - end - -- use proxy? local envs local proxy_conf = proxy.config() if proxy_conf then -- get proxy configuration from the current remote url - local remoteinfo = try { function() return os.iorunv(git.program, {"remote", "-v"}) end } + local remoteinfo = try { function() return os.iorunv(git.program, {"remote", "-v"}, {curdir = opt.repodir}) end } if remoteinfo then for _, line in ipairs(remoteinfo:split('\n', {plain = true})) do local splitinfo = line:split("%s+") @@ -86,10 +80,5 @@ function main(opt) end -- pull it - os.vrunv(git.program, argv, {envs = envs}) - - -- leave repository directory - if oldir then - os.cd(oldir) - end + os.vrunv(git.program, argv, {envs = envs, curdir = opt.repodir}) end -- cgit v1.3.1