2 from yap
.yap
import YapCore
3 from yap
.util
import get_output
, takes_options
7 class TCommitPlugin(YapCore
):
8 "Provide a 'temporory commit' mechanism"
10 def _add_branch(self
, branch
):
11 repo
= get_output("git rev-parse --git-dir")
14 dir = os
.path
.join(repo
[0], 'yap')
19 state_file
= os
.path
.join(dir, 'tcommit')
21 b
= self
._get
_branches
()
23 pickle
.dump(b
, file(state_file
, 'w'))
25 def _get_branches(self
):
26 repo
= get_output("git rev-parse --git-dir")
27 state_file
= os
.path
.join(repo
[0], 'yap', 'tcommit')
30 b
= pickle
.load(file(state_file
))
35 def _remove_branch(self
, branch
):
36 repo
= get_output("git rev-parse --git-dir")
39 state_file
= os
.path
.join(repo
[0], 'yap', 'tcommit')
41 b
= self
._get
_branches
()
43 pickle
.dump(b
, file(state_file
, 'w'))
46 def cmd_commit(self
, *args
, **flags
):
50 flags
= {'-a': 1, '-m': 'yap wip'}
54 super(TCommitPlugin
, self
).cmd_commit(*args
, **flags
)
57 branch
= get_output("git symbolic-ref HEAD")
59 self
._add
_branch
(branch
[0])
61 def cmd_branch(self
, *args
, **flags
):
65 self
._remove
_branch
(branch
)
67 super(TCommitPlugin
, self
).cmd_branch(*args
, **flags
)
69 def cmd_switch(self
, *args
, **flags
):
70 super(TCommitPlugin
, self
).cmd_switch(*args
, **flags
)
72 branch
= get_output("git symbolic-ref HEAD")
73 if branch
[0] in self
._get
_branches
():
75 self
._remove
_branch
(branch
[0])