Beispiel #1
0
def _get_git_next_version_suffix(branch_name):
    datestamp = datetime.datetime.now().strftime('%Y%m%d')
    if branch_name == 'milestone-proposed':
        revno_prefix = "r"
    else:
        revno_prefix = ""
    if os.environ.get('JENKINS_URL', None):
        run_shell_command("git fetch origin +refs/meta/*:refs/remotes/meta/*")
        milestone_cmd = "git show meta/openstack/release:%s" % branch_name
        milestonever = run_shell_command(milestone_cmd)
        if not milestonever:
            milestonever = ""
    else:
        milestonever = ""
    post_version = _get_git_post_version()
    # post version should look like:
    # 0.1.1.4.gcc9e28a
    # where the bit after the last . is the short sha, and the bit between
    # the last and second to last is the revno count
    (revno, sha) = post_version.split(".")[-2:]
    first_half = "%(milestonever)s~%(datestamp)s" % \
        dict(datestamp=datestamp,
             milestonever=milestonever)
    second_half = "%(revno_prefix)s%(revno)s.%(sha)s" % \
        dict(sha=sha,
             revno_prefix=revno_prefix,
             revno=revno)
    return ".".join((first_half, second_half))
Beispiel #2
0
def _get_git_next_version_suffix(branch_name):
    datestamp = datetime.datetime.now().strftime('%Y%m%d')
    if branch_name == 'milestone-proposed':
        revno_prefix = "r"
    else:
        revno_prefix = ""
    if os.environ.get('JENKINS_URL', None):
        run_shell_command("git fetch origin +refs/meta/*:refs/remotes/meta/*")
        milestone_cmd = "git show meta/openstack/release:%s" % branch_name
        milestonever = run_shell_command(milestone_cmd)
        if not milestonever:
            milestonever = ""
    else:
        milestonever = ""
    post_version = _get_git_post_version()
    # post version should look like:
    # 0.1.1.4.gcc9e28a
    # where the bit after the last . is the short sha, and the bit between
    # the last and second to last is the revno count
    (revno, sha) = post_version.split(".")[-2:]
    first_half = "%(milestonever)s~%(datestamp)s" % \
        dict(datestamp=datestamp,
             milestonever=milestonever)
    second_half = "%(revno_prefix)s%(revno)s.%(sha)s" % \
        dict(sha=sha,
             revno_prefix=revno_prefix,
             revno=revno)
    return ".".join((first_half, second_half))
Beispiel #3
0
def generate_authors():
    """Create AUTHORS file using git commits."""
    jenkins_email = '*****@*****.**'
    old_authors = 'AUTHORS.in'
    new_authors = 'AUTHORS'
    if os.path.isdir('.git'):
        # don't include jenkins email address in AUTHORS file
        git_log_cmd = ("git log --format='%aN <%aE>' | sort -u | "
                       "grep -v " + jenkins_email)
        author_entries = util.run_shell_command(git_log_cmd).split("\n")
        signed_cmd = "git log | grep Co-authored-by: | sort -u"
        signed_entries = util.run_shell_command(signed_cmd)
        if signed_entries:
            author_entries.extend([
                signed.split(":", 1)[1].strip()
                for signed in signed_entries.split("\n")
            ])
        mailmap = parse_mailmap()
        authors = list(
            set([
                canonicalize_emails(author, mailmap)
                for author in author_entries
            ]))
        authors.sort()
        with open(new_authors, 'w') as new_authors_fh:
            new_authors_fh.write("\n".join(authors))
            if os.path.exists(old_authors):
                with open(old_authors, "r") as old_authors_fh:
                    new_authors_fh.write('\n' + old_authors_fh.read())
Beispiel #4
0
def _get_git_branchname():
    branch_ref = run_shell_command("git symbolic-ref -q HEAD")
    if branch_ref == "":
        _branch_name = "HEAD"
    else:
        _branch_name = branch_ref[len("refs/heads/"):]
    return _branch_name
Beispiel #5
0
def _get_git_branchname():
    branch_ref = run_shell_command("git symbolic-ref -q HEAD")
    if branch_ref == "":
        _branch_name = "HEAD"
    else:
        _branch_name = branch_ref[len("refs/heads/"):]
    return _branch_name
Beispiel #6
0
def _get_git_post_version():
    current_tag = _get_git_current_tag()
    if current_tag is not None:
        return current_tag
    else:
        tag_info = _get_git_tag_info()
        if tag_info is None:
            base_version = "0.0"
            cmd = "git --no-pager log --oneline"
            out = run_shell_command(cmd)
            revno = len(out.split("\n"))
            sha = run_shell_command("git describe --always")
        else:
            tag_infos = tag_info.split("-")
            base_version = "-".join(tag_infos[:-2])
            (revno, sha) = tag_infos[-2:]
        return "%s.%s.%s" % (base_version, revno, sha)
Beispiel #7
0
def _get_git_post_version():
    current_tag = _get_git_current_tag()
    if current_tag is not None:
        return current_tag
    else:
        tag_info = _get_git_tag_info()
        if tag_info is None:
            base_version = "0.0"
            cmd = "git --no-pager log --oneline"
            out = run_shell_command(cmd)
            revno = len(out.split("\n"))
            sha = run_shell_command("git describe --always")
        else:
            tag_infos = tag_info.split("-")
            base_version = "-".join(tag_infos[:-2])
            (revno, sha) = tag_infos[-2:]
        return "%s.%s.%s" % (base_version, revno, sha)
Beispiel #8
0
def write_git_changelog():
    """Write a changelog based on the git changelog."""
    if os.path.isdir('.git'):
        git_log_cmd = 'git log --stat'
        changelog = util.run_shell_command(git_log_cmd)
        mailmap = parse_mailmap()
        with open("ChangeLog", "w") as changelog_file:
            changelog_file.write(canonicalize_emails(changelog, mailmap))
Beispiel #9
0
def write_git_changelog():
    """Write a changelog based on the git changelog."""
    if os.path.isdir(".git"):
        git_log_cmd = "git log --stat"
        changelog = util.run_shell_command(git_log_cmd)
        mailmap = parse_mailmap()
        with open("ChangeLog", "w") as changelog_file:
            changelog_file.write(canonicalize_emails(changelog, mailmap))
Beispiel #10
0
def generate_authors():
    """Create AUTHORS file using git commits."""
    jenkins_email = "*****@*****.**"
    old_authors = "AUTHORS.in"
    new_authors = "AUTHORS"
    if os.path.isdir(".git"):
        # don't include jenkins email address in AUTHORS file
        git_log_cmd = "git log --format='%aN <%aE>' | sort -u | " "grep -v " + jenkins_email
        author_entries = util.run_shell_command(git_log_cmd).split("\n")
        signed_cmd = "git log | grep Co-authored-by: | sort -u"
        signed_entries = util.run_shell_command(signed_cmd)
        if signed_entries:
            author_entries.extend([signed.split(":", 1)[1].strip() for signed in signed_entries.split("\n")])
        mailmap = parse_mailmap()
        authors = list(set([canonicalize_emails(author, mailmap) for author in author_entries]))
        authors.sort()
        with open(new_authors, "w") as new_authors_fh:
            new_authors_fh.write("\n".join(authors))
            if os.path.exists(old_authors):
                with open(old_authors, "r") as old_authors_fh:
                    new_authors_fh.write("\n" + old_authors_fh.read())
Beispiel #11
0
def _get_git_tag_info():
    return run_shell_command("git describe --tags")
Beispiel #12
0
def _get_git_current_tag():
    return run_shell_command("git tag --contains HEAD")
Beispiel #13
0
def _get_git_tag_info():
    return run_shell_command("git describe --tags")
Beispiel #14
0
def _get_git_current_tag():
    return run_shell_command("git tag --contains HEAD")