From c13f637b72a9f8b3344cd0101147ca23e1a6759b Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Mon, 21 Aug 2017 14:25:27 +0100 Subject: Sanitise track checking Updated to use ref if tracking or no sha specified. unpetrify-ref is deprecated. --- ybd/config/ybd.conf | 4 ++-- ybd/repos.py | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'ybd') diff --git a/ybd/config/ybd.conf b/ybd/config/ybd.conf index 27e60eb..d9ac612 100644 --- a/ybd/config/ybd.conf +++ b/ybd/config/ybd.conf @@ -210,8 +210,8 @@ tar-url: 'http://git.baserock.org/tarballs' # else, set TMPDIR # TMPDIR: /tmp -# Normally ybd builds at whatever version is set in the 'ref:' field -# If we set 'track-branches:', then ybd will attempt to build 'unpetrify-ref:' +# Normally ybd builds at whatever version is set in the 'sha:' field +# If we set 'track-branches:', then ybd will attempt to build 'ref:' # track-branches: [path/to/foo-chunk, path/to/bar-chunk, path/to/bip-chunk] # track-branches: True diff --git a/ybd/repos.py b/ybd/repos.py index 099a9f3..9674ee9 100644 --- a/ybd/repos.py +++ b/ybd/repos.py @@ -100,11 +100,9 @@ def get_last_tag(gitdir): def get_tree(dn): info = get_transport_info(dn['repo']) - ref = str(dn.get('sha', str(dn.get('ref')))) - track = app.config.get('track-branches') - if dn.get('unpetrify-ref') and track: - if track is True or dn['path'] in track: - ref = str(dn['unpetrify-ref']) + track = app.config.get('track-branches', []) + track = (isinstance(track, list) and dn['path'] in track) or track + ref = dn.get('ref') if track else dn.get('sha', dn.get('ref')) gitdir = info['dir'] if dn['repo'].startswith('file://') or dn['repo'].startswith('/'): @@ -124,8 +122,8 @@ def get_tree(dn): mirror(dn['name'], dn['repo']) with app.chdir(gitdir), open(os.devnull, "w") as fnull: - if call(['git', 'rev-parse', ref + '^{object}'], stdout=fnull, - stderr=fnull): + if track or call(['git', 'rev-parse', ref + '^{object}'], + stdout=fnull, stderr=fnull): # can't resolve ref. is it upstream? app.log(dn, 'Fetching from upstream to resolve %s' % ref) update_mirror(dn['name'], dn['repo'], gitdir) -- cgit v1.2.1