<commit_before>import git
import os
import logging

logging.basicConfig(level=logging.INFO)

logging.info('Updating package version info')

root_path = os.path.dirname(__file__)
logging.info('Root path:\t{}'.format(root_path))

repo = git.Repo(root_path)
logging.info('Repo:\t{}'.format(repo))

latest_tag = repo.tags[-1]
logging.info('Latest tag:\t{}'.format(latest_tag))

# current_branch = repo.active_branch
# logging.info('Current branch:\t{}'.format(current_branch))

travis_commit = os.environ.get('TRAVIS_COMMIT')
logging.info('Travis commit:\t{}'.format(travis_commit))

travis_branch = os.environ.get('TRAVIS_BRANCH')
logging.info('Travis branch:\t{}'.format(travis_branch))

travis_pr_branch = os.environ.get('TRAVIS_PULL_REQUEST_BRANCH')
logging.info('Travis PR branch:\t{}'.format(travis_pr_branch))

travis_tag = os.environ.get('TRAVIS_TAG')
logging.info('Travis tag:\t{}'.format(travis_tag))


sha = repo.head.object.hexsha
logging.info('Last commit sha:\t{}'.format(sha))

short_sha = repo.git.rev_parse(sha, short=4)
logging.info('Last commit short sha:\t{}'.format(short_sha))

if str(current_branch) == 'master':
    version = '{}'.format(latest_tag)
else:
    version = '{}+{}'.format(latest_tag, short_sha)

logging.info('Package version:\t{}'.format(version))

output_file = os.path.join(root_path, 'VERSION')
logging.info('Writing version info to:\t{}'.format(output_file))
with open(output_file, 'w') as f:
    f.write(version)

logging.info('Version update complete')<commit_msg>using travis variables to help versioning<commit_after>import git
import os
import logging

logging.basicConfig(level=logging.INFO)

logging.info('Updating package version info')

root_path = os.path.dirname(__file__)
logging.info('Root path:\t{}'.format(root_path))

repo = git.Repo(root_path)
logging.info('Repo:\t{}'.format(repo))

latest_tag = repo.tags[-1]
logging.info('Latest tag:\t{}'.format(latest_tag))

travis_commit = os.environ.get('TRAVIS_COMMIT')
logging.info('Travis commit:\t{}'.format(travis_commit))

sha = repo.head.object.hexsha
logging.info('Last commit sha:\t{}'.format(sha))

short_sha = repo.git.rev_parse(sha, short=4)
logging.info('Last commit short sha:\t{}'.format(short_sha))

travis_branch = os.environ.get('TRAVIS_BRANCH')
logging.info('Travis branch:\t{}'.format(travis_branch))

travis_pr_branch = os.environ.get('TRAVIS_PULL_REQUEST_BRANCH')
logging.info('Travis PR branch:\t{}'.format(travis_pr_branch))

travis_tag = os.environ.get('TRAVIS_TAG')
logging.info('Travis tag:\t{}'.format(travis_tag))

if len(travis_tag) > 0:
    version = '{}'.format(latest_tag)
else:
    version = '{}+{}'.format(latest_tag, short_sha)

logging.info('Package version:\t{}'.format(version))

output_file = os.path.join(root_path, 'VERSION')
logging.info('Writing version info to:\t{}'.format(output_file))
with open(output_file, 'w') as f:
    f.write(version)

logging.info('Version update complete')
{'fraction_non_alphanumeric': 0.17413616147793362, 'fraction_numerical': 0.0017105713308244953, 'mean_word_length': 6.839142091152815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3663455', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1064, 'n_words': 164}