-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
71 lines (48 loc) · 1.75 KB
/
manage.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /usr/bin/env python
from os import chdir
from os.path import exists
from sys import argv
from base import *
import tmux as tm
import dmenu as dm
__all__ = (
"manage",
)
git_bin = "git"
def git(*args, **kwargs):
return cmd(git_bin, *args, **kwargs)
def manage(mode):
tpl = "https://bozso:%s@github.com/bozso"
assert mode in ("git", "tmux")
if argv[1] == "git":
if len(argv) > 2 and argv[2] == "all":
repo = "all"
mode = dm.select("pull", "commit", "status",
p="Select action for all repositories:")
else:
repo = dm.select("all", p="Select a repository:", **repos)
mode = dm.select("pull", "commit", "status", p="Select action:")
if repo == "all":
_repos = repos
else:
_repos = {repo: repos[repo]}
if mode in ("pull", "commit"):
pwd = dm.password(p="Github password:")
tpl = tpl % pwd
for name, path in _repos.items():
if not exists(path):
continue
chdir(path)
if mode == "pull":
notify(git("pull", "%s/%s" % (tpl, name)),
header="Pulling repositroy %s." % name,
icon="github.png")
elif mode == "commit":
msg = din(p="Commit message:")
git("commit", '-am "%s"' % msg)
git("push", "%s/%s" % (tpl, name))
elif mode == "status":
notify(git("status"), header="Repository %s status." % name,
icon="github.png")
elif argv[1] == "tmux":
pass