Commit 459ae8a9 authored by Jan-Tarek Butt's avatar Jan-Tarek Butt

firmware-bot: fix dir exsysting check

parent 3998fe80
......@@ -25,6 +25,8 @@ local SITE_CONF="/tmp/siteconf/site.conf"
-- config end --
require("lfs")
if io.open(PID_PART, "r") ~=nil then
io.stderr:write("The firmware-bot is still running.\n")
os.exit(1)
......@@ -73,6 +75,14 @@ local function check_manifest_symlink(firmware_dir)
end
end
function isDir(name)
if type(name)~="string" then return false end
local cd = lfs.currentdir()
local is = lfs.chdir(name) and true or false
lfs.chdir(cd)
return is
end
-- check code into directory out. If it already exists fetch code up to commit ID
local function checkout_git(pwd, dir, repo, branch)
if pwd:sub(-1,-1):match("/") then
......@@ -80,7 +90,7 @@ local function checkout_git(pwd, dir, repo, branch)
end
local mygit="git -C " .. pwd .. "/" .. dir
io.stderr:write("checking out " .. repo .. " to " .. pwd .. "/" .. dir .. " in version " .. branch .. "\n")
if os.execute("[ -d " .. pwd .. "/" .. dir .. " ]") then
if isDir(pwd .. "/" .. dir) then
if os.execute(mygit .. " remote -v | grep -q \"" .. repo .. "\"") then
io.stderr:write("Right remote detected\n")
if not os.execute(mygit .. " checkout \"" .. branch .. "\"") then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment