Beispiel #1
0
def make_git_commit(changelog_file, message):
  """
    :param message: string message for the commit.
  """
  info('making git commit: "{}"', message)
  return shell(
    "git add {} && git commit -am {}".format(changelog_file, message))
Beispiel #2
0
def get_commits_no_merges(to):
  """
    :param to:
  """
  separator = "__||__"
  logs = shell("git log --no-merges --pretty=%B{} {}..".format(separator, to))
  return [_.strip() for _ in logs.output()[0].split(separator)]
Beispiel #3
0
def get_commits(start, to, format, grep):
  """
  returns list of git commits

    :params start: defaults to the latest git tag.
    :params to: defaults to 'HEAD'
    :params format: defaults to %H%n%s%n%b%n==DEL==
    :params grep: defaults to "feat|^fix|BREAKING"
  """
  if start is None:
    start = get_latest_git_tag()

  if to is None:
    to = 'HEAD'

  if start is not None and len(start) > 0:
    commit_range = "{}..{}".format(start, to)
  else:
    commit_range = ""

  if grep is None:
    grep = "feat|^fix|BREAKING"

  if format is None:
    format = "%H%n%s%n%b%n{}".format(delimiter)

  delimiter = "==DEL=="

  command = "git log --grep=\"^{}\" -E --format='{}' {}".format(
    grep, format, commit_range)

  commits = shell(command).output().split('\n{}\n'.format(delimiter))
  for commit in commits:
    parse_raw_commit(commit)
Beispiel #4
0
def get_commits(start, to, format, grep):
    """
  returns list of git commits

    :params start: defaults to the latest git tag.
    :params to: defaults to 'HEAD'
    :params format: defaults to %H%n%s%n%b%n==DEL==
    :params grep: defaults to "feat|^fix|BREAKING"
  """
    if start is None:
        start = get_latest_git_tag()

    if to is None:
        to = 'HEAD'

    if start is not None and len(start) > 0:
        commit_range = "{}..{}".format(start, to)
    else:
        commit_range = ""

    if grep is None:
        grep = "feat|^fix|BREAKING"

    if format is None:
        format = "%H%n%s%n%b%n{}".format(delimiter)

    delimiter = "==DEL=="

    command = "git log --grep=\"^{}\" -E --format='{}' {}".format(
        grep, format, commit_range)

    commits = shell(command).output().split('\n{}\n'.format(delimiter))
    for commit in commits:
        parse_raw_commit(commit)
Beispiel #5
0
def make_git_commit(changelog_file, message):
    """
    :param message: string message for the commit.
  """
    info('making git commit: "{}"', message)
    return shell("git add {} && git commit -am {}".format(
        changelog_file, message))
Beispiel #6
0
def get_commits_no_merges(to):
    """
    :param to:
  """
    separator = "__||__"
    logs = shell("git log --no-merges --pretty=%B{} {}..".format(
        separator, to))
    return [_.strip() for _ in logs.output()[0].split(separator)]
Beispiel #7
0
def get_current_git_tag():
    """
    :returns: string of the current git tag on the git index, not the latest
              tag version created.
  """
    tag = shell("git describe --tags").output()[0]
    if "-" in tag:
        tag = tag.split('-')[0]
    # TODO: test semantic ver here?
    return tag
Beispiel #8
0
def get_current_git_tag():
  """
    :returns: string of the current git tag on the git index, not the latest
              tag version created.
  """
  tag = shell("git describe --tags").output()[0]
  if "-" in tag:
    tag = tag.split('-')[0]
  # TODO: test semantic ver here?
  return tag
Beispiel #9
0
def get_first_commit():
    """
  returns the first commit with a oneline prettyprint.
  """
    return shell("git log --format=\"%H\" --pretty=oneline --reverse")
Beispiel #10
0
def git_stash():
    """
  stashes current changes in git.
  """
    return shell("git stash")
Beispiel #11
0
def git_checkout(id):
    """
    :param id: string identifier of the commit'ish to checkout.
  """
    info('checking out: "{}"', id)
    return shell("git checkout {}".format(id))
Beispiel #12
0
def git_diff_files():
    """
    :returns: list of string names of the files that are dirty.
  """
    files = shell("git diff --minimal --numstat").output()
    return [x.split("\t")[-1] for x in files]
Beispiel #13
0
def git_stash():
  """
  stashes current changes in git.
  """
  return shell("git stash")
Beispiel #14
0
def has_uncommitted_changes():
    return len(
        shell("git diff-index --cached HEAD --ignore-submodules").output()) > 0
Beispiel #15
0
def get_git_tags():
    """
    :returns: list of git tags, sorted by the date of the commit it points to.
  """
    return shell("git for-each-ref --format='%(tag)' refs/tags").output()
Beispiel #16
0
def make_git_tag(msg, tag_name):
  """
    :param tag_name: string name for the tag.
  """
  info('making git tag: "{}"', tag_name)
  return shell("git tag {} -m {}".format(tag_name, msg))
Beispiel #17
0
def push_to_remote():
    """
  pushes current branch and tags to remote.
  """
    # don't call --all here on purpose..
    return shell("git push && git push --tags")
Beispiel #18
0
def has_unstaged_changes():
  return len(shell("git diff-files --ignore-submodules").output()) > 0
Beispiel #19
0
def get_latest_git_tag():
  """
    :returns: list of git tags, sorted by the date of the commit it points to.
  """
  return shell("git describe --tags --abbrev=0").output()[0]
Beispiel #20
0
def get_git_tags():
  """
    :returns: list of git tags, sorted by the date of the commit it points to.
  """
  return shell("git for-each-ref --format='%(tag)' refs/tags").output()
Beispiel #21
0
def get_first_commit():
  """
  returns the first commit with a oneline prettyprint.
  """
  return shell("git log --format=\"%H\" --pretty=oneline --reverse")
Beispiel #22
0
def has_unstaged_changes():
    return len(shell("git diff-files --ignore-submodules").output()) > 0
Beispiel #23
0
def get_unstaged_files():
  return shell(
    "git diff-files --name-status -r --ignore-submodules").output()
Beispiel #24
0
def push_to_remote():
  """
  pushes current branch and tags to remote.
  """
  # don't call --all here on purpose..
  return shell("git push && git push --tags")
Beispiel #25
0
def make_git_tag(msg, tag_name):
    """
    :param tag_name: string name for the tag.
  """
    info('making git tag: "{}"', tag_name)
    return shell("git tag {} -m {}".format(tag_name, msg))
Beispiel #26
0
def has_uncommitted_changes():
  return len(shell(
    "git diff-index --cached HEAD --ignore-submodules").output()) > 0
Beispiel #27
0
def get_uncommitted_files():
  return shell(
    "git diff-index --cached --name-status -r --ignore-submodules HEAD").output()
Beispiel #28
0
def git_diff_files():
  """
    :returns: list of string names of the files that are dirty.
  """
  files = shell("git diff --minimal --numstat").output()
  return [x.split("\t")[-1] for x in files]
Beispiel #29
0
def get_latest_git_tag():
    """
    :returns: list of git tags, sorted by the date of the commit it points to.
  """
    return shell("git describe --tags --abbrev=0").output()[0]
def setup_py_distribute():
  """
  uploads a dist build to the python package index.
  """
  return shell("{} setup.py clean sdist upload".format(sys.executable))
Beispiel #31
0
def get_unstaged_files():
    return shell(
        "git diff-files --name-status -r --ignore-submodules").output()
Beispiel #32
0
def setup_py_distribute():
    """
  uploads a dist build to the python package index.
  """
    return shell("{} setup.py clean sdist upload".format(sys.executable))
Beispiel #33
0
def get_uncommitted_files():
    return shell(
        "git diff-index --cached --name-status -r --ignore-submodules HEAD"
    ).output()
Beispiel #34
0
def git_checkout(id):
  """
    :param id: string identifier of the commit'ish to checkout.
  """
  info('checking out: "{}"', id)
  return shell("git checkout {}".format(id))