def validate_data_repo_updated(logger, config): repo = Repo(config['releasewarrior_data_repo']) if repo.is_dirty(): logger.fatal("release data repo dirty. Aborting...") return False upstream = find_upstream_repo(repo, logger, config) # TODO - we should allow csets to exist locally that are not on remote. logger.info( "ensuring releasewarrior repo is up to date and in sync with {}". format(upstream)) logger.debug('pulling new csets from {}/master'.format(upstream)) try: # XXX ff_only=True is overriden by user's gitconfig. Known case: when user set # rebase = true upstream.pull(ff_only=True) except git_exc.GitCommandError as e: logger.fatal('Could not pull changes from {}/master: {}'.format( upstream, e)) commits_behind = list( repo.iter_commits('master..{}/master'.format(upstream))) if commits_behind: logger.fatal('local master is behind {}/master.'.format(upstream)) return False return True
def validate_data_repo_updated(logger, config): repo = Repo(config['releasewarrior_data_repo']) if repo.is_dirty(): logger.warning("release data repo dirty") upstream = find_upstream_repo(repo, logger, config) # TODO - we should allow csets to exist locally that are not on remote. logger.info("ensuring releasewarrior repo is up to date and in sync with {}".format(upstream)) logger.debug('fetching new csets from {}/master'.format(upstream)) upstream.fetch() commits_behind = list(repo.iter_commits('master..{}/master'.format(upstream))) if commits_behind: logger.fatal('local master is behind {}/master.'.format(upstream)) return False return True
def validate_rw_repo(logger, config): if os.environ.get("RW_DEV"): logger.debug("Skipping rw repo validation because RW_DEV is set") return # data repo state file state_file = os.path.join(config['releasewarrior_data_repo'], 'state.yml') min_sha = None if os.path.isfile(state_file): with open(state_file) as fh: state = yaml.load(fh) min_sha = state.get('min-rw-sha') else: logger.warning('no release data state file') return if not min_sha: logger.warning( 'no release data information on minimum sha for releasewarrior') if not re.match('[0-9a-fA-F]', min_sha): logger.fatal('min sha ({}) is invalid format'.format(min_sha)) sys.exit(1) repo = Repo(RW_REPO) if repo.is_dirty(): logger.warning("releasewarrior repo dirty") upstream = find_upstream_repo( repo, logger, config, pattern_key='upstream_rw_repo_url_pattern', simplified_pattern_key='simplified_rw_repo_url') logger.info("ensuring releasewarrior repo is newer than {} from {}".format( min_sha, upstream)) try: repo.git.merge_base('--is-ancestor', min_sha, repo.head.commit) except git_exc.GitCommandError: logger.fatal( 'Local releasewarrior repo does not contain {} please pull' 'in newer content'.format(min_sha)) sys.exit(1)