Add some more coding style improvements to fetch.git

parent ed7a57c8
......@@ -22,9 +22,8 @@
"""Module providing the stuff for handling Git repositories"""
import os
from hdlmake.util import path
from hdlmake.util import path as path_utils
import logging
import platform
from tempfile import TemporaryFile
from subprocess import Popen, PIPE
from .constants import GIT
......@@ -44,7 +43,7 @@ class Git(Fetcher):
"""Get the top level for the Git repository"""
cur_dir = module.pool.top_module.path
try:
os.chdir(path.rel2abs(module.path))
os.chdir(path_utils.rel2abs(module.path))
if not os.path.exists(".gitmodules"):
return None
tree_root_cmd = Popen("git rev-parse --show-toplevel",
......@@ -66,9 +65,9 @@ class Git(Fetcher):
cur_dir = module.pool.top_module.path
if module.branch is None:
module.branch = "master"
basename = path.url_basename(module.url)
basename = path_utils.url_basename(module.url)
mod_path = os.path.join(fetchto, basename)
logging.info("Fetching git module: %s" % mod_path)
logging.info("Fetching git module: %s", mod_path)
if basename.endswith(".git"):
basename = basename[:-4] # remove trailing .git
if module.isfetched:
......@@ -76,22 +75,22 @@ class Git(Fetcher):
else:
update_only = False
if update_only:
logging.info("Updating module %s" % mod_path)
logging.info("Updating module %s", mod_path)
cmd = "(cd {0} && git checkout {1})"
cmd = cmd.format(mod_path, module.branch)
else:
logging.info("Cloning module %s" % mod_path)
logging.info("Cloning module %s", mod_path)
cmd = "(cd {0} && git clone -b {2} {1})"
cmd = cmd.format(fetchto, module.url, module.branch)
success = True
logging.debug("Running %s" % cmd)
logging.debug("Running %s", cmd)
if os.system(cmd) != 0:
success = False
if module.revision is not None and success is True:
logging.debug("cd %s" % mod_path)
logging.debug("cd %s", mod_path)
os.chdir(mod_path)
cmd = "git checkout " + module.revision
logging.debug("Running %s" % cmd)
logging.debug("Running %s", cmd)
if os.system(cmd) != 0:
success = False
os.chdir(cur_dir)
......@@ -106,7 +105,7 @@ class Git(Fetcher):
commit = None
stderr = TemporaryFile()
try:
is_windows = path.check_windows()
is_windows = path_utils.check_windows()
os.chdir(path)
git_cmd = 'git log -1 --format="%H" | cut -c1-32'
git_out = Popen(git_cmd,
......@@ -118,8 +117,8 @@ class Git(Fetcher):
errmsg = stderr.readlines()
if errmsg:
logging.debug(
"git error message (in %s): %s" %
(path, '\n'.join(errmsg)))
"git error message (in %s): %s",
path, '\n'.join(errmsg))
try:
commit = git_out.stdout.readlines()[0].strip()
except IndexError:
......
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