Skip to content

Instantly share code, notes, and snippets.

@philippbosch
Forked from wolever/git-blast
Created November 30, 2016 14:24
Show Gist options
  • Select an option

  • Save philippbosch/5d25d225bb9510eb49de6ff74e7f4de7 to your computer and use it in GitHub Desktop.

Select an option

Save philippbosch/5d25d225bb9510eb49de6ff74e7f4de7 to your computer and use it in GitHub Desktop.

Revisions

  1. philippbosch revised this gist Nov 30, 2016. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions git-blast
    Original file line number Diff line number Diff line change
    @@ -19,13 +19,17 @@ merged:
    """

    import subprocess as sp
    import sys

    def xcall(cmd):
    return sp.check_output(cmd.split()).decode("utf-8")

    C_GREEN = '\033[0;32m'
    C_BLUE = '\033[0;34m'
    C_RESET = '\033[0;0m'
    if sys.stdout.isatty():
    C_GREEN = '\033[0;32m'
    C_BLUE = '\033[0;34m'
    C_RESET = '\033[0;0m'
    else:
    C_GREEN = C_BLUE = C_RESET = ''

    cur_branch = xcall("git rev-parse --abbrev-ref HEAD").strip()
    merged_branches = set([
  2. @wolever wolever revised this gist May 20, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-blast
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ merged:
    import subprocess as sp

    def xcall(cmd):
    return sp.check_output(cmd.split())
    return sp.check_output(cmd.split()).decode("utf-8")

    C_GREEN = '\033[0;32m'
    C_BLUE = '\033[0;34m'
    @@ -47,4 +47,4 @@ for line in by_date.splitlines():
    output += " %s%s%s" %(C_BLUE, date, C_RESET)
    if branch in merged_branches and branch != cur_branch:
    output += " [%sM%s]" %(C_GREEN, C_RESET)
    print output
    print(output)
  3. @wolever wolever revised this gist Feb 16, 2015. 1 changed file with 47 additions and 28 deletions.
    75 changes: 47 additions & 28 deletions git-blast
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,50 @@
    #!/bin/bash
    # Shows git branches sorted by last commit date.
    # $ git blast
    # * master 33 minutes ago
    # david 4 days ago
    # unholy-david-payments 4 days ago
    # handsontable-2 5 days ago
    # payments 5 days ago
    # ask-inst-type 7 days ago
    # legacy 2 weeks ago
    # archive 2 weeks ago
    # upload 3 weeks ago
    # david-old 4 months ago
    # dbscan 5 months ago
    # matrix-fun 5 months ago
    #!/usr/bin/env python
    """
    Shows git branches sorted by last commit date, noting when branch has been
    merged:
    IFS="`printf "\n\t"`"
    set -eu
    $ git blast
    * master 33 minutes ago
    david 4 days ago [M]
    unholy-david-payments 4 days ago
    handsontable-2 5 days ago
    payments 5 days ago [M]
    ask-inst-type 7 days ago
    legacy 2 weeks ago
    archive 2 weeks ago
    upload 3 weeks ago
    david-old 4 months ago
    dbscan 5 months ago
    matrix-fun 5 months ago
    """

    GREEN='\033[0;32m'
    import subprocess as sp

    cur_branch="$(git rev-parse --abbrev-ref HEAD)"
    git for-each-ref --sort=-committerdate refs/heads/ \
    --format="%(refname:short) %1B[0;34m%(committerdate:relative)%1B[0;m" | \
    while read LINE; do
    if [[ "$LINE" =~ ^$cur_branch ]]; then
    echo -e "* $GREEN$LINE"
    else
    echo -e " $LINE"
    fi
    done
    def xcall(cmd):
    return sp.check_output(cmd.split())

    C_GREEN = '\033[0;32m'
    C_BLUE = '\033[0;34m'
    C_RESET = '\033[0;0m'

    cur_branch = xcall("git rev-parse --abbrev-ref HEAD").strip()
    merged_branches = set([
    x.split()[-1] for x
    in xcall("git branch --merged").splitlines()
    ])

    by_date = xcall(
    "git for-each-ref --sort=-committerdate refs/heads/ "
    "--format=%(refname:short)%09%(committerdate:relative)"
    )
    for line in by_date.splitlines():
    branch, _, date = line.partition("\t")
    output = ""
    if branch == cur_branch:
    output += "* %s%s" %(C_GREEN, branch)
    else:
    output += " %s" %(branch, )
    output += " %s%s%s" %(C_BLUE, date, C_RESET)
    if branch in merged_branches and branch != cur_branch:
    output += " [%sM%s]" %(C_GREEN, C_RESET)
    print output
  4. @wolever wolever created this gist Feb 16, 2015.
    31 changes: 31 additions & 0 deletions git-blast
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/bin/bash
    # Shows git branches sorted by last commit date.
    # $ git blast
    # * master 33 minutes ago
    # david 4 days ago
    # unholy-david-payments 4 days ago
    # handsontable-2 5 days ago
    # payments 5 days ago
    # ask-inst-type 7 days ago
    # legacy 2 weeks ago
    # archive 2 weeks ago
    # upload 3 weeks ago
    # david-old 4 months ago
    # dbscan 5 months ago
    # matrix-fun 5 months ago

    IFS="`printf "\n\t"`"
    set -eu

    GREEN='\033[0;32m'

    cur_branch="$(git rev-parse --abbrev-ref HEAD)"
    git for-each-ref --sort=-committerdate refs/heads/ \
    --format="%(refname:short) %1B[0;34m%(committerdate:relative)%1B[0;m" | \
    while read LINE; do
    if [[ "$LINE" =~ ^$cur_branch ]]; then
    echo -e "* $GREEN$LINE"
    else
    echo -e " $LINE"
    fi
    done