Skip to content

Commit a947ec8

Browse files
committed
Support reporting SCM branches if supported by server (fix #51)
1 parent a436a08 commit a947ec8

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

backslash/contrib/slash_plugin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ def _update_scm_info(self, test_info):
332332
hexsha = None
333333
test_info['scm_revision'] = hexsha
334334
test_info['scm_dirty'] = bool(repo.untracked_files or repo.index.diff(None) or repo.index.diff(repo.head.commit))
335+
if self.client.api.info().endpoints.report_test_start.version >= 3:
336+
test_info['scm_local_branch'] = repo.active_branch.name
337+
tracking_branch = repo.active_branch.tracking_branch()
338+
if tracking_branch is not None:
339+
test_info['scm_remote_branch'] = tracking_branch.name
335340
except Exception: # pylint: disable=broad-except
336341
_logger.warning('Error when obtaining SCM information', exc_info=True)
337342

backslash/session.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def send_keepalive(self):
2727
self.client.api.call_function('send_keepalive', {'session_id': self.id})
2828

2929
def report_test_start(self, name, file_name=NOTHING, class_name=NOTHING, test_logical_id=NOTHING, scm=NOTHING,
30-
file_hash=NOTHING, scm_revision=NOTHING, scm_dirty=NOTHING, is_interactive=NOTHING,
31-
variation=NOTHING, metadata=NOTHING, test_index=NOTHING, parameters=NOTHING):
30+
file_hash=NOTHING,
31+
scm_revision=NOTHING, scm_dirty=NOTHING, scm_local_branch=NOTHING, scm_remote_branch=NOTHING,
32+
is_interactive=NOTHING, variation=NOTHING, metadata=NOTHING, test_index=NOTHING, parameters=NOTHING):
3233

3334
params = {
3435
'session_id': self.id,
@@ -37,6 +38,8 @@ def report_test_start(self, name, file_name=NOTHING, class_name=NOTHING, test_lo
3738
'file_hash': file_hash,
3839
'scm_revision': scm_revision,
3940
'scm_dirty': scm_dirty,
41+
'scm_local_branch': scm_local_branch,
42+
'scm_remote_branch': scm_remote_branch,
4043
'class_name': class_name,
4144
'file_name': file_name,
4245
'is_interactive': is_interactive,

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Changelog
22
=========
33

4+
* :feature:`51` Report local and remote SCM branches if supported
45
* :release: `2.30.0 <8-8-2017>`
56
* :feature:`50` Added session_webapp_url property to the Slash plugin
67
* :release:`2.29.0 <6-8-2017>`

0 commit comments

Comments
 (0)