def object_metadata(module, repo_path): """Metadata for the ddrlocal/ddrcmdln and models definitions used. @param module: collection, entity, files model definitions module @param repo_path: Absolute path to root of object's repo @returns: dict """ if not config.APP_METADATA: repo = dvcs.repository(repo_path) config.APP_METADATA['git_version'] = '; '.join([ dvcs.git_version(repo), dvcs.annex_version(repo) ]) # ddr-cmdln url = 'https://github.com/densho/ddr-cmdln.git' config.APP_METADATA['application'] = url config.APP_METADATA['app_path'] = config.INSTALL_PATH config.APP_METADATA['app_commit'] = dvcs.latest_commit( config.INSTALL_PATH ) config.APP_METADATA['app_release'] = VERSION # ddr-defs config.APP_METADATA['defs_path'] = modules.Module(module).path config.APP_METADATA['defs_commit'] = dvcs.latest_commit( modules.Module(module).path ) return config.APP_METADATA
def test_latest_commit(): path = os.path.join(TESTING_BASE_DIR, 'testrepo') # rm existing if os.path.exists(path): shutil.rmtree(path) # set up repos repo = make_repo(path, ['testing']) # test at repo root out1 = dvcs.latest_commit(path) # test individual file path_to_file = os.path.join(path, 'testing') out2 = dvcs.latest_commit(path_to_file) # analyze regex = r'([0123456789abcdef]+)\s+\([a-zA-Z]+ -> [a-zA-Z-]+\) ([0-9-]+) ([0-9:]+) (-[0-9]+)' assert re.match(regex, out1) assert re.match(regex, out2)
def test_latest_commit(tmpdir): path = str(tmpdir / 'testrepo') # rm existing if os.path.exists(path): shutil.rmtree(path) # set up repos repo = make_repo(path, ['testing']) # test at repo root out1 = dvcs.latest_commit(path) # test individual file path_to_file = os.path.join(path, 'testing') out2 = dvcs.latest_commit(path_to_file) # analyze regex = r'([0123456789abcdef]+)\s+\([a-zA-Z]+ -> [a-zA-Z-]+\) ([0-9-]+) ([0-9:]+) (-[0-9]+)' assert re.match(regex, out1) assert re.match(regex, out2)
def object_metadata(module, repo_path): """Metadata for the ddrlocal/ddrcmdln and models definitions used. @param module: collection, entity, files model definitions module @param repo_path: Absolute path to root of object's repo @returns: dict """ repo = dvcs.repository(repo_path) gitversion = '; '.join([dvcs.git_version(repo), dvcs.annex_version(repo)]) data = { 'application': 'https://github.com/densho/ddr-cmdln.git', 'app_commit': dvcs.latest_commit(config.INSTALL_PATH), 'app_release': VERSION, 'defs_path': modules.Module(module).path, 'models_commit': dvcs.latest_commit(modules.Module(module).path), 'git_version': gitversion, } return data
def module_commit(self): return self._parse_commit(dvcs.latest_commit(self.path))
from DDR.config import CONFIG_FILES, NoConfigError config = ConfigParser.ConfigParser() configs_read = config.read(CONFIG_FILES) if not configs_read: raise NoConfigError('No config file!') REPO_MODELS_PATH = config.get('cmdln','repo_models_path') if REPO_MODELS_PATH not in sys.path: sys.path.append(REPO_MODELS_PATH) # Latest commits for ddr-cmdln and ddr-local. # Include here in settings so only has to be retrieved once, # and so commits are visible in error pages and in page footers. from DDR import dvcs DDRCMDLN_INSTALL_PATH = config.get('cmdln','install_path') DDRCMDLN_COMMIT = dvcs.latest_commit(DDRCMDLN_INSTALL_PATH) DDRLOCAL_COMMIT = dvcs.latest_commit(os.path.dirname(__file__)) # The following settings are in debian/config/ddr.cfg. # See that file for comments on the settings. # ddr.cfg is installed in /etc/ddr/ddr.cfg. # Settings in /etc/ddr/ddr.cfg may be overridden in /etc/ddr/local.cfg. GITOLITE = config.get('workbench','gitolite') GITOLITE_TIMEOUT = config.get('workbench','gitolite_timeout') CGIT_URL = config.get('workbench','cgit_url') GIT_REMOTE_NAME = config.get('workbench','remote') IDSERVICE_API_BASE = config.get('idservice','api_base') MEDIA_BASE = config.get('cmdln','media_base') # Location of Repository 'ddr' repo, which should contain repo_models
from __future__ import absolute_import # This will make sure the app is always imported when # Django starts so that shared_task will use this app. from .celery import app as celery_app from DDR.dvcs import latest_commit VERSION = '0.9.2-beta' COMMIT = latest_commit()
import pytz # import all settings from ddr-cmdln DDR/config.py # including the ConfigParser object CONFIG from DDR.config import * os.environ['USER'] = '******' AGENT = 'ddr-local' # Latest commits for ddr-cmdln and ddr-local. # Include here in settings so only has to be retrieved once, # and so commits are visible in error pages and in page footers. from DDR import dvcs dvcs.APP_COMMITS['loc'] = dvcs.latest_commit(os.path.dirname(__file__)) APP_COMMITS_HTML = '<br/>\n'.join([ 'loc: %s' % dvcs.APP_COMMITS['loc'], 'cmd: %s' % dvcs.APP_COMMITS['cmd'], 'def: %s' % dvcs.APP_COMMITS['def'], 'def: %s' % REPO_MODELS_PATH, ]) # The following settings are in debian/config/ddr.cfg. # See that file for comments on the settings. # ddr.cfg is installed in /etc/ddr/ddr.cfg. # Settings in /etc/ddr/ddr.cfg may be overridden in /etc/ddr/local.cfg. GITOLITE = CONFIG.get('workbench','gitolite') GITOLITE_TIMEOUT = CONFIG.get('workbench','gitolite_timeout') CGIT_URL = CONFIG.get('workbench','cgit_url')