Changeset 1519d11 in rtems-source-builder
- Timestamp:
- 09/22/17 01:55:10 (5 years ago)
- Branches:
- 5, master
- Children:
- 55f2d69
- Parents:
- e6d0a8b
- git-author:
- Chris Johns <chrisj@…> (09/22/17 01:55:10)
- git-committer:
- Chris Johns <chrisj@…> (09/22/17 01:59:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source-builder/sb/git.py
re6d0a8b r1519d11 71 71 raise error.general('invalid version string from git: %s' % (output)) 72 72 vs = gvs[2].split('.') 73 if len(vs) != 4:73 if len(vs) not in [3, 4]: 74 74 raise error.general('invalid version number from git: %s' % (gvs[2])) 75 return (int(vs[0]), int(vs[1]), int(vs[2]), int(vs[3]))75 return tuple(map(int, vs)) 76 76 77 77 def clone(self, url, _path): … … 106 106 ec, output = self._run(['submodule', 'update', '--init', module], check = True) 107 107 108 def submodules(self): 109 smodules = {} 110 ec, output = self._run(['submodule'], check = True) 111 if ec == 0: 112 for l in output.split('\n'): 113 ms = l.split() 114 if len(ms) == 3: 115 smodules[ms[1]] = (ms[0], ms[2][1:-1]) 116 return smodules 117 108 118 def clean(self, args = []): 109 119 if type(args) == str: … … 111 121 ec, output = self._run(['clean'] + args, check = True) 112 122 113 def status(self ):123 def status(self, submodules_always_clean = False): 114 124 _status = {} 115 125 if path.exists(self.path): 126 if submodules_always_clean: 127 submodules = self.submodules() 128 else: 129 submodules = {} 116 130 ec, output = self._run(['status']) 117 131 if ec == 0: … … 134 148 l = l.strip() 135 149 if l[0] != '(': 136 if state not in _status:137 _status[state] = []138 l = l[1:]139 150 if ':' in l: 140 151 l = l.split(':')[1] 141 _status[state] += [l.strip()] 152 if len(l.strip()) > 0: 153 l = l.strip() 154 ls = l.split() 155 if state != 'unstaged' or ls[0] not in submodules: 156 if state not in _status: 157 _status[state] = [l] 158 else: 159 _status[state] += [l] 142 160 return _status 143 161 144 162 def dirty(self): 145 163 _status = self.status() 164 _status.pop('untracked', None) 165 _status.pop('detached', None) 146 166 return not (len(_status) == 1 and 'branch' in _status) 147 167 … … 201 221 202 222 if __name__ == '__main__': 223 import os.path 203 224 import sys 204 opts = options.load(sys.argv) 225 defaults = path.join(path.dirname(path.dirname(path.shell(sys.argv[0]))), 'defaults.mc') 226 opts = options.load(sys.argv, defaults = defaults) 205 227 g = repo('.', opts) 206 print(g.git_version()) 207 print(g.valid()) 208 print(g.status()) 209 print(g.clean()) 210 print(g.remotes()) 211 print(g.email()) 212 print(g.head()) 228 print('g.git_version():', g.git_version()) 229 print('g.valid():', g.valid()) 230 print('g.submodules():', g.submodules()) 231 print('g.status():', g.status()) 232 print('g.status():', g.status(True)) 233 print('g.dirty():', g.dirty()) 234 print('g.remotes():', g.remotes()) 235 print('g.email():', g.email()) 236 print('g.head():', g.head())
Note: See TracChangeset
for help on using the changeset viewer.