forked from SublimeGit/SublimeGit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SublimeGit.py
91 lines (73 loc) · 2.27 KB
/
SublimeGit.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
# coding: utf-8
import sys
import logging
import sublime
# set up some logging
logging.basicConfig(level=logging.WARNING, format="[%(asctime)s - %(levelname)-8s - %(name)s] %(message)s")
logger = logging.getLogger('SublimeGit')
# reload modules if necessary
LOAD_ORDER = [
# base
'',
'.util',
'.cmd',
'.helpers',
# commands
'.help',
'.cli',
'.repo',
'.diff',
'.show',
'.blame',
'.log',
'.stash',
'.branch',
'.remote',
'.status',
'.add',
'.commit',
'.checkout',
'.merge',
# meta
'.sublimegit',
# extensions
'.git_extensions.legit',
'.git_extensions.git_flow',
]
needs_reload = [n for n, m in list(sys.modules.items()) if n[0:4] == 'sgit' and m is not None]
reloaded = []
for postfix in LOAD_ORDER:
module = 'sgit' + postfix
if module in needs_reload:
reloaded.append(module)
reload(sys.modules[module])
if reloaded:
logger.info('Reloaded %s' % ", ".join(reloaded))
# import commands and listeners
if sys.version_info[0] == 2:
settings = sublime.load_settings('SublimeGit.sublime-settings')
# set log level
lvl = getattr(logging, settings.get('log_level', '').upper(), logging.WARNING)
logger.setLevel(lvl)
from sgit import * # noqa
from sgit.git_extensions.legit import * # noqa
from sgit.git_extensions.git_flow import * # noqa
# Enable plugins
git_extensions.legit.enabled = settings.get('git_extensions', {}).get('legit', True)
git_extensions.git_flow.enabled = settings.get('git_extensions', {}).get('git_flow', True)
def unload_handler():
logging.shutdown()
else:
from .sgit import * # noqa
from .sgit.git_extensions.legit import * # noqa
from .sgit.git_extensions.git_flow import * # noqa
def plugin_loaded():
settings = sublime.load_settings('SublimeGit.sublime-settings')
# set log level
lvl = getattr(logging, settings.get('log_level', '').upper(), logging.WARNING)
logger.setLevel(lvl)
# Enable plugins
git_extensions.legit.enabled = settings.get('git_extensions', {}).get('legit', True)
git_extensions.git_flow.enabled = settings.get('git_extensions', {}).get('git_flow', True)
def plugin_unloaded():
logging.shutdown()