Skip to content
Snippets Groups Projects
Commit 94927fc0 authored by Pawel Szostek's avatar Pawel Szostek
Browse files

Add branch specification to repos' urls

parent 2ccf38b3
No related merge requests found
No preview for this file type
......@@ -55,13 +55,12 @@ class ModulePool(list):
cur_dir = os.getcwd()
os.chdir(module.fetchto)
url, rev = self.__parse_repo_url(module.url)
cmd = "svn checkout {0} " + module.basename
if rev:
cmd = cmd.format(url + '@' + rev)
cmd = cmd.format(module.url + '@' + module.revision)
else:
cmd = cmd.format(url)
cmd = cmd.format(module.url)
rval = True
......@@ -71,7 +70,6 @@ class ModulePool(list):
os.chdir(cur_dir)
module.isfetched = True
module.revision = rev
module.path = os.path.join(module.fetchto, module.basename)
return rval
......@@ -80,9 +78,10 @@ class ModulePool(list):
os.mkdir(module.fetchto)
cur_dir = os.getcwd()
url, rev = self.__parse_repo_url(module.url)
if module.branch == None:
module.branch = "master"
basename = path.url_basename(url)
basename = path.url_basename(module.url)
mod_path = os.path.join(module.fetchto, basename)
if basename.endswith(".git"):
......@@ -94,11 +93,11 @@ class ModulePool(list):
update_only = False
if update_only:
cmd = "(cd {0} && git pull)"
cmd = cmd.format(mod_path)
cmd = "(cd {0} && git checkout {1})"
cmd = cmd.format(mod_path, module.branch)
else:
cmd = "(cd {0} && git clone {1})"
cmd = cmd.format(module.fetchto, url)
cmd = "(cd {0} && git clone -b {2} {1})"
cmd = cmd.format(module.fetchto, module.url, module.branch)
rval = True
......@@ -106,35 +105,18 @@ class ModulePool(list):
if os.system(cmd) != 0:
rval = False
if rev and rval:
if module.revision and rval:
os.chdir(mod_path)
cmd = "git checkout " + rev
cmd = "git checkout " + module.revision
p.vprint(cmd)
if os.system(cmd) != 0:
rval = False
os.chdir(cur_dir)
module.isfetched = True
module.revision = rev
module.path = mod_path
return rval
def __parse_repo_url(self, url) :
"""
Check if link to a repo seems to be correct. Filter revision number
"""
import re
url_pat = re.compile("[ \t]*([^ \t]+)[ \t]*(@[ \t]*(.+))?[ \t]*")
url_match = re.match(url_pat, url)
if url_match == None:
p.echo("Not a correct repo url: {0}. Skipping".format(url))
if url_match.group(3) != None: #there is a revision given
ret = (url_match.group(1), url_match.group(3))
else:
ret = (url_match.group(1), None)
return ret
#end class ModuleFetcher
def __init__(self):
self.top_module = None
......
......@@ -47,6 +47,7 @@ class Module(object):
return path.url_basename(self.url)
def __init__(self, parent, url, source, fetchto, pool):
import path
self.fetchto = fetchto
self.pool = pool
self.source = source
......@@ -65,7 +66,10 @@ class Module(object):
self.revision = None
self._files = None
self.manifest = None
self.url = url
if source != "local":
self.url, self.branch, self.revision = path.url_parse(url)
else:
self.url, self.branch, self.revision = url, None, None
if source == "local" and not os.path.exists(url):
p.rawprint("Path to the local module doesn't exist:\n" + url)
......
......@@ -20,6 +20,7 @@
#
import os
import msg as p
ise_path_64 = {
"10.0":"/opt/Xilinx/10.0/ISE/bin/lin",
......@@ -37,11 +38,37 @@ ise_path_32 = {"10.0":"/opt/Xilinx/10.0/ISE/bin/lin",
"12.4":"/opt/Xilinx/12.4/ISE_DS/ISE/bin/lin64",
"13.1":"/opt/Xilinx/13.1/ISE_DS/ISE/bin/lin64"}
def url_parse(url):
"""
Check if link to a repo seems to be correct. Filter revision number and branch
"""
import re
print "<<<" + url
"""url_pat = re.compile("[ \t]*([^ \t]+?)[ \t]*(::)?([^ \t@]+)?(@[ \t]*(.+))?[ \t]*")
url_match = re.match(url_pat, url)
if url_match == None:
p.echo("Not a correct repo url: {0}. Skipping".format(url))
url_clean = url_match.group(1)
if url_match.group(3) != None: #there is a branch
branch = url_match.group(3)
if url_match.group(5) != None: #there is a revision given
rev = url_match.group(5)"""
url_clean, branch, rev = None, None, None
if "@@" in url:
url_clean, rev = url.split("@@")
elif "::" in url:
url_clean, branch = url.split("::")
else:
url_clean = url
print url_clean, branch, rev
return (url_clean, branch, rev)
def url_basename(url):
"""
Get basename from an url
"""
if url.endswith(".git"):
ret = os.path.basename(url[:-4])
elif url[-1] == '/':
......
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