2 from yap
import YapPlugin
3 from yap
.util
import get_output
, takes_options
7 class TCommitPlugin(YapPlugin
):
8 def __init__(self
, yap
):
11 def _add_branch(self
, branch
):
12 repo
= get_output("git rev-parse --git-dir")
15 dir = os
.path
.join(repo
[0], 'yap')
20 state_file
= os
.path
.join(dir, 'tcommit')
22 b
= self
._get
_branches
()
24 pickle
.dump(b
, file(state_file
, 'w'))
26 def _get_branches(self
):
27 repo
= get_output("git rev-parse --git-dir")
28 state_file
= os
.path
.join(repo
[0], 'yap', 'tcommit')
31 b
= pickle
.load(file(state_file
))
36 def _remove_branch(self
, branch
):
37 repo
= get_output("git rev-parse --git-dir")
40 state_file
= os
.path
.join(repo
[0], 'yap', 'tcommit')
42 b
= self
._get
_branches
()
44 pickle
.dump(b
, file(state_file
, 'w'))
47 def cmd_commit(self
, *args
, **flags
):
49 self
.yap
.cmd_commit(*[], **{'-a': 1, '-m': 'yap wip'})
50 branch
= get_output("git symbolic-ref HEAD")
52 self
._add
_branch
(branch
[0])
54 self
.yap
._call
_base
("cmd_commit", *args
, **flags
)
56 def post_switch(self
):
57 branch
= get_output("git symbolic-ref HEAD")
58 if branch
[0] in self
._get
_branches
():
59 self
.yap
.cmd_uncommit()
60 self
._remove
_branch
(branch
[0])