forked from soccin/Variant-PostProcess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannotateMAF.py
More file actions
28 lines (23 loc) · 951 Bytes
/
Copy pathannotateMAF.py
File metadata and controls
28 lines (23 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
import sh
import os.path
import sys
import datetime
def printAnnotation(fp=sys.stdout):
SDIR=os.path.dirname(os.path.realpath(sys.argv[0]))
GITDIR="--git-dir=%s/.git" % (SDIR)
WORKTREE="--work-tree=%s" % (SDIR)
VERSIONBRANCH=sh.git(GITDIR,WORKTREE,"describe","--all").strip()
VERSIONTAG=sh.git(GITDIR,WORKTREE,"describe","--long","--always").strip()
try:
REMOTE_ORIGIN_URL=sh.git(GITDIR,WORKTREE,"config","--get","remote.origin.url").strip()
except:
REMOTE_ORIGIN_URL=SDIR
UNTRACKED=sh.git(GITDIR,WORKTREE,"status","--porcelain").strip()
if UNTRACKED!="":
UNTRACKED=" [UnCommitted Changes %s]" % (str(datetime.datetime.today()))
print >>fp, "#CBE:%s (%s) (%s)%s" % (REMOTE_ORIGIN_URL,VERSIONBRANCH,VERSIONTAG,UNTRACKED)
print >>fp, "#CBE:%s %s" % (os.path.realpath(sys.argv[0]),
" ".join(sys.argv[1:]))
if __name__=="__main__":
printAnnotation()