Exemple #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))
Exemple #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)]
Exemple #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)
Exemple #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)
Exemple #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))
Exemple #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)]
Exemple #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
Exemple #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
Exemple #9
0
def get_first_commit():
    """
  returns the first commit with a oneline prettyprint.
  """
    return shell("git log --format=\"%H\" --pretty=oneline --reverse")
Exemple #10
0
def git_stash():
    """
  stashes current changes in git.
  """
    return shell("git stash")
Exemple #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))
Exemple #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]
Exemple #13
0
def git_stash():
  """
  stashes current changes in git.
  """
  return shell("git stash")
Exemple #14
0
def has_uncommitted_changes():
    return len(
        shell("git diff-index --cached HEAD --ignore-submodules").output()) > 0
Exemple #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()
Exemple #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))
Exemple #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")
Exemple #18
0
def has_unstaged_changes():
  return len(shell("git diff-files --ignore-submodules").output()) > 0
Exemple #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]
Exemple #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()
Exemple #21
0
def get_first_commit():
  """
  returns the first commit with a oneline prettyprint.
  """
  return shell("git log --format=\"%H\" --pretty=oneline --reverse")
Exemple #22
0
def has_unstaged_changes():
    return len(shell("git diff-files --ignore-submodules").output()) > 0
Exemple #23
0
def get_unstaged_files():
  return shell(
    "git diff-files --name-status -r --ignore-submodules").output()
Exemple #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")
Exemple #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))
Exemple #26
0
def has_uncommitted_changes():
  return len(shell(
    "git diff-index --cached HEAD --ignore-submodules").output()) > 0
Exemple #27
0
def get_uncommitted_files():
  return shell(
    "git diff-index --cached --name-status -r --ignore-submodules HEAD").output()
Exemple #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]
Exemple #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))
Exemple #31
0
def get_unstaged_files():
    return shell(
        "git diff-files --name-status -r --ignore-submodules").output()
Exemple #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))
Exemple #33
0
def get_uncommitted_files():
    return shell(
        "git diff-index --cached --name-status -r --ignore-submodules HEAD"
    ).output()
Exemple #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))