Commit 7b6ae833 authored by Paweł Szostek's avatar Paweł Szostek

add revision checking in SVN and GIT

parent 0b196b78
......@@ -3,6 +3,7 @@
import os
import path
import logging
from subprocess import Popen, PIPE
class Git(object):
......@@ -61,3 +62,15 @@ class Git(object):
module.isfetched = True
module.path = mod_path
return success
@staticmethod
def check_commit_id(path):
cur_dir = os.getcwd()
try:
os.chdir(path)
git_cmd = 'git log -1 --format="%H" | cut -c1-32'
git_out = Popen(git_cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True)
commit = git_out.stdout.readlines()[0].strip()
finally:
os.chdir(cur_dir)
return commit
......@@ -3,6 +3,7 @@
import os
import logging
import path
from subprocess import Popen, PIPE
class Svn(object):
......@@ -36,3 +37,15 @@ class Svn(object):
module.isfetched = True
module.path = os.path.join(module.fetchto, module.basename)
return success
@staticmethod
def check_revision_number(path):
cur_dir = os.getcwd()
try:
os.chdir(path)
svn_cmd = "svn info | awk '{if(NR == 5) {print $2}}'"
svn_out = Popen(svn_cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True)
revision = svn_out.stdout.readlines()[0].strip()
finally:
os.chdir(cur_dir)
return revision
......@@ -10,6 +10,8 @@ import path as path_mod
import os
import global_mod
import logging
import fetch
import sys
class Module(object):
......@@ -72,8 +74,9 @@ class Module(object):
self.syn_post_script = None
self.sim_only_files = None
self.sim_pre_script = None
self.sim_post_scritp = None
self.sim_post_script = None
self.top_module = None
self.commit_id = None
if source != "local":
self.url, self.branch, self.revision = path.url_parse(url)
......@@ -172,6 +175,10 @@ class Module(object):
self.manifest = self.__search_for_manifest()
if self.path is None:
raise RuntimeError()
if self.source == "svn":
self.revision = fetch.svn.check_revision_number(self.path)
elif self.source == "git":
self.revision = fetch.git.check_commit_id(self.path)
manifest_parser = ManifestParser()
# For non-top modules
......@@ -360,17 +367,17 @@ class Module(object):
if filepath:
if path_mod.is_abs_path(filepath):
logging.warning("Specified path seems to be an absolute path: %s\nOmitting." % filepath)
#return False
return True
filepath = path_mod.rel2abs(filepath, self.path)
return False
filepath = os.path.join(self.path, filepath)
if not os.path.exists(filepath):
logging.error("Specified path doesn't exist: %s" % filepath)
quit()
logging.error("Path specified in %s doesn't exist: %s" % (self.path, filepath))
sys.exit("Exiting")
filepath = path_mod.rel2abs(filepath, self.path)
if not os.path.isfile(filepath):
logging.warning("Specified path is not a normal file: %s\nOmitting." % filepath)
#return False
return True
if os.path.isdir(filepath):
logging.warning("Path specified in %s is a directory: %s" % (self.path, filepath))
return True
def is_fetched_recursively(self):
......
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