def gitrepo(root): tmpdir = sh.pwd().strip() sh.cd(root) gitlog = sh.git('--no-pager', 'log', '-1', pretty="format:%s" % FORMAT).split('\n', 5) branch = os.environ.get('CIRCLE_BRANCH') or os.environ.get('TRAVIS_BRANCH', sh.git('rev-parse', '--abbrev-ref', 'HEAD').strip()) remotes = [x.split() for x in filter(lambda x: x.endswith('(fetch)'), sh.git.remote('-v').strip().splitlines())] sh.cd(tmpdir) return { "head": { "id": gitlog[0], "author_name": gitlog[1], "author_email": gitlog[2], "committer_name": gitlog[3], "committer_email": gitlog[4], "message": gitlog[5].strip(), }, "branch": branch, "remotes": [{'name': remote[0], 'url': remote[1]} for remote in remotes] }
try: input_ver = raw_input('Please provide build number: ') if semver.from_string(input_ver) <= previous_build_number: raise semver.SemanticVersionError( '\tVersion cannot be less than: %s' % previous_build_number) return input_ver except semver.SemanticVersionError, e: print e if __name__ == '__main__': try: root_dir = pwd().strip() revision = retrieve_git_revision() previous_build_number = semver.from_string(retreive_build_number()) print 'Previous build: ', previous_build_number new_build_number = '%d.%d.%d' % (previous_build_number.major, previous_build_number.minor, previous_build_number.patchlevel + 1) if raw_input('Use "%s" as next build number? (yes) ' % (new_build_number, )) != 'yes': new_build_number = prompt_for_new_build_number( previous_build_number) git_check_for_tag_collision(new_build_number)
def prompt_for_new_build_number(previous_build_number): while True: try: input_ver = raw_input('Please provide build number: ') if semver.from_string(input_ver) <= previous_build_number: raise semver.SemanticVersionError('\tVersion cannot be less than: %s' % previous_build_number) return input_ver except semver.SemanticVersionError, e: print e if __name__ == '__main__': try: root_dir = pwd().strip() revision = retrieve_git_revision() previous_build_number = semver.from_string(retreive_build_number()) print 'Previous build: ', previous_build_number new_build_number = '%d.%d.%d' % ( previous_build_number.major, previous_build_number.minor, previous_build_number.patchlevel + 1) if raw_input('Use "%s" as next build number? (yes) ' % (new_build_number,)) != 'yes': new_build_number = prompt_for_new_build_number(previous_build_number) git_check_for_tag_collision(new_build_number) build_version_code = new_build_number.replace('.', '')