-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
31 lines (26 loc) · 962 Bytes
/
config.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
import os
import imp
class Config(object):
BRANCH_PATTERN = r'^\w{2,3}/(\d+)'
COMMIT_PATTERN = '[#{story_num}] {message}'
BASE_BRANCH = 'master'
def __init__(self):
self.load_rcfile(self.find_rcfile())
with os.popen('git branch --list main') as p:
if p.read().strip():
Config.BASE_BRANCH = 'main'
def find_rcfile(self):
with os.popen('git rev-parse --show-toplevel') as p:
gitdir = p.readline().rstrip('\n') + '/.git'
usrdir = os.path.expanduser('~')
for rcfile in [gitdir+'/.dhrc', usrdir+'/.dhrc', None]:
if rcfile is None or os.path.exists(rcfile):
break
return rcfile
def load_rcfile(self, rcfile):
if rcfile is None:
return
rc = imp.load_source('devhelpers_rc', rcfile)
for p in dir(rc):
if not p.startswith('__'):
setattr(self, p, getattr(rc, p))