forked from kemayo/sublime-text-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_commands.py
92 lines (77 loc) · 2.47 KB
/
git_commands.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from __future__ import absolute_import, unicode_literals, print_function, division
import sys
"""This module collates the Git commands from the submodule
...it's a python 2 / 3 compatibility workaround, mostly.
"""
# Sublime doesn't reload submodules. This code is based on 1_reloader.py
# in Package Control, and handles that.
mod_prefix = 'git'
# ST3 loads each package as a module, so it needs an extra prefix
if sys.version_info >= (3,):
bare_mod_prefix = mod_prefix
mod_prefix = 'Git.' + mod_prefix
from imp import reload
# Modules have to be reloaded in dependency order. So list 'em here:
mods_load_order = [
'',
'.status',
'.add', # imports status
'.index', # imports status
'.commit', # imports add
# no interdependencies below
'.core',
'.annotate',
'.config',
'.diff',
'.history',
'.ignore',
'.repo',
'.stash',
'.statusbar',
'.flow',
'.file',
]
reload_mods = [mod for mod in sys.modules if mod[0:3] in ('git', 'Git') and sys.modules[mod] is not None]
reloaded = []
for suffix in mods_load_order:
mod = mod_prefix + suffix
if mod in reload_mods:
reload(sys.modules[mod])
reloaded.append(mod)
if reloaded:
print("Git: reloaded submodules", reloaded)
# Now actually import all the commands so they'll be visible to Sublime
try:
# Python 3
from .git.core import * # noqa
from .git.add import * # noqa
from .git.index import * # noqa
from .git.annotate import * # noqa
from .git.config import * # noqa
from .git.commit import * # noqa
from .git.diff import * # noqa
from .git.flow import * # noqa
from .git.history import * # noqa
from .git.file import * # noqa
from .git.ignore import * # noqa
from .git.repo import * # noqa
from .git.stash import * # noqa
from .git.status import * # noqa
from .git.statusbar import * # noqa
except (ImportError, ValueError):
# Python 2
from git.core import * # noqa
from git.add import * # noqa
from git.index import * # noqa
from git.annotate import * # noqa
from git.config import * # noqa
from git.commit import * # noqa
from git.diff import * # noqa
from git.flow import * # noqa
from git.history import * # noqa
from git.file import * # noqa
from git.ignore import * # noqa
from git.repo import * # noqa
from git.stash import * # noqa
from git.status import * # noqa
from git.statusbar import * # noqa