File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 41
41
42
42
43
43
def extract_status (value ):
44
- """Returns `git status -sb --porcelain=2` extracted to a dict
44
+ """Returns `` git status -sb --porcelain=2` ` extracted to a dict
45
45
46
46
:returns: Dictionary of git repo's status
47
47
:rtype: str
@@ -516,12 +516,31 @@ def get_git_version(self):
516
516
version = ''
517
517
return '.' .join (version .split ('.' )[:3 ])
518
518
519
+ def status (self ):
520
+ """Retrieve status of project in dict format.
521
+
522
+ Wraps ``git status --sb --porcelain=2``. Does not include changed files, yet.
523
+
524
+ .. code-block:: python
525
+
526
+ print(git_repo.status())
527
+ {
528
+ "branch_oid": 'de6185fde0806e5c7754ca05676325a1ea4d6348',
529
+ "branch_head": 'fix-current-remote-name',
530
+ "branch_upstream": 'origin/fix-current-remote-name',
531
+ "branch_ab": '+0 -0',
532
+ "branch_ahead": '0',
533
+ "branch_behind": '0',
534
+ }
535
+ """
536
+ return extract_status (self .run (['status' , '-sb' , '--porcelain=2' ]))
537
+
519
538
def get_current_remote_name (self ):
520
539
"""Retrieve name of the remote / upstream of currently checked out branch.
521
540
522
541
:rtype: str, None if no remote set
523
542
"""
524
- match = extract_status ( self .run ([ ' status' , '-sb' , '--porcelain=2' ]) )
543
+ match = self .status ( )
525
544
526
545
if match ['branch_upstream' ] is None : # no upstream set
527
546
return match ['branch_head' ]
You can’t perform that action at this time.
0 commit comments