Skip to content

Instantly share code, notes, and snippets.

@linuxcaffe
Forked from wbsch/on-exit_git.py
Created November 24, 2016 05:41

Revisions

  1. @wbsch wbsch revised this gist Apr 5, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions on-exit_git.py
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    # Inspired by https://gist.github.com/Unode/9366218
    #
    # Works with any Taskwarrior version that supports hooks.
    # Needs Taskwarrior-NOT_PUBLIC_YET in order to show fancy commit messages.
    # Needs Taskwarrior 2.4.3 in order to show fancy commit messages.
    #
    # NOTE: Little to no error handling. This is a PoC, remember?

    @@ -19,8 +19,8 @@
    TASK_DIR = os.path.dirname(__file__) + os.sep + os.pardir

    c = {}
    if len(sys.argv) > 2:
    c = {k:v for k, v in (s.split(":", 1) for s in sys.argv[2:])}
    if len(sys.argv) > 1:
    c = {k:v for k, v in (s.split(":", 1) for s in sys.argv[1:])}

    if 'args' not in c:
    c['args'] = "Taskwarrior version too old, no info available."
  2. @wbsch wbsch revised this gist Mar 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion on-exit_git.py
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@
    c = {k:v for k, v in (s.split(":", 1) for s in sys.argv[2:])}

    if 'args' not in c:
    args['c'] = "Taskwarrior version too old, no info available."
    c['args'] = "Taskwarrior version too old, no info available."

    os.chdir(TASK_DIR)

  3. @wbsch wbsch revised this gist Mar 28, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions on-exit_git.py
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@
    with open(".gitignore", "w") as f:
    f.write("*\n")
    subprocess.call("git add -f .gitignore pending.data completed.data".split())
    subprocess.call(["git", "commit", "-m'Initial log'"])
    subprocess.call(["git", "commit", "-mInitial log"])

    if subprocess.call("git diff --exit-code --quiet".split()) != 0:
    subprocess.call("git commit -a".split() + ["-m'" + c['args'].replace("'", "") + "'"])
    subprocess.call("git commit -a".split() + ["-m" + c['args']])
  4. @wbsch wbsch revised this gist Mar 28, 2015. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion on-exit_git.py
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,13 @@
    #
    # PoC: Manage a git repository in ~/.task that gets updated on changes.
    # Only pending.data and completed.data are included by default.
    # You can use "git add" to add whatever files you want to track in your
    # task folder.
    #
    # Inspired by https://gist.github.com/Unode/9366218
    #
    # Needs Taskwarrior-NOT_PUBLIC_YET in order to work.
    # Works with any Taskwarrior version that supports hooks.
    # Needs Taskwarrior-NOT_PUBLIC_YET in order to show fancy commit messages.
    #
    # NOTE: Little to no error handling. This is a PoC, remember?

  5. @wbsch wbsch revised this gist Mar 28, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions on-exit_git.py
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,9 @@
    if len(sys.argv) > 2:
    c = {k:v for k, v in (s.split(":", 1) for s in sys.argv[2:])}

    if 'args' not in c:
    args['c'] = "Taskwarrior version too old, no info available."

    os.chdir(TASK_DIR)

    if not os.path.isdir(TASK_DIR + os.sep + ".git"):
  6. @wbsch wbsch created this gist Mar 28, 2015.
    32 changes: 32 additions & 0 deletions on-exit_git.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/usr/bin/env python
    #
    # PoC: Manage a git repository in ~/.task that gets updated on changes.
    # Only pending.data and completed.data are included by default.
    #
    # Inspired by https://gist.github.com/Unode/9366218
    #
    # Needs Taskwarrior-NOT_PUBLIC_YET in order to work.
    #
    # NOTE: Little to no error handling. This is a PoC, remember?

    import os
    import subprocess
    import sys

    TASK_DIR = os.path.dirname(__file__) + os.sep + os.pardir

    c = {}
    if len(sys.argv) > 2:
    c = {k:v for k, v in (s.split(":", 1) for s in sys.argv[2:])}

    os.chdir(TASK_DIR)

    if not os.path.isdir(TASK_DIR + os.sep + ".git"):
    subprocess.call("git init".split())
    with open(".gitignore", "w") as f:
    f.write("*\n")
    subprocess.call("git add -f .gitignore pending.data completed.data".split())
    subprocess.call(["git", "commit", "-m'Initial log'"])

    if subprocess.call("git diff --exit-code --quiet".split()) != 0:
    subprocess.call("git commit -a".split() + ["-m'" + c['args'].replace("'", "") + "'"])