Skip to content

Instantly share code, notes, and snippets.

@ccfontes
Created March 21, 2018 09:46
Show Gist options
  • Save ccfontes/13c22b9cc89795831d288f56373b67d4 to your computer and use it in GitHub Desktop.
Save ccfontes/13c22b9cc89795831d288f56373b67d4 to your computer and use it in GitHub Desktop.
On git commit, adds message with JIRA ticket name and time spent working on commit to the commit editor
#!/usr/bin/env hy
(import sys)
(import subprocess)
(import [pathlib [Path]])
(import [functools [partial]])
(setv current-branch-name (subprocess.check_output ["git" "symbolic-ref" "--short" "HEAD"] :encoding "utf-8"))
(setv work-time (subprocess.check_output ["glass" "-s" "status" "--commit-template"] :encoding "utf-8"))
(setv ticket_name (-> (.split current-branch-name "/") second (.split "_") first))
(defn jira-cmds-to-file [tkt-name time filename]
(.write_text (Path filename) (+ tkt-name " " time " ")))
(if (-> sys.argv len (= 2))
(jira-cmds-to-file ticket_name work-time (get sys.argv 1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment