Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

Commit cf1d146

Browse files
committed
bug reporter can redirect visitors to commit
1 parent 7f28967 commit cf1d146

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

BugReporter.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77

88
commit = None
9+
short_commit = None
910
git_source = None
1011
bugs = dict()
1112
build_state = 'passing'
@@ -26,6 +27,7 @@ def quick_config(file_path_ = 'bugs.json', use_git_=True, git_='git', git_source
2627
def get_data():
2728
return {
2829
'commit':commit,
30+
'short_commit': short_commit,
2931
'bugs':bugs,
3032
'build_state':build_state,
3133
'bugs_count':bugs_count
@@ -53,13 +55,13 @@ def load_file(file_path_):
5355

5456

5557
def get_git_info():
56-
global commit, git_source
58+
global commit, git_source, short_commit
5759
dir = os.path.dirname(__file__)
5860
if dir != '':
5961
os.chdir(dir)
6062
try:
61-
short_hash = subprocess.check_output([git, 'describe', '--always'], stderr=subprocess.STDOUT).strip().decode()
62-
commit = subprocess.check_output([git, 'rev-parse', short_hash], stderr=subprocess.STDOUT).strip().decode()
63+
short_commit = subprocess.check_output([git, 'describe', '--always'], stderr=subprocess.STDOUT).strip().decode()
64+
commit = subprocess.check_output([git, 'rev-parse', short_commit], stderr=subprocess.STDOUT).strip().decode()
6365
except subprocess.CalledProcessError:
6466
logging.error('There was an error - command exited with non-zero code')
6567
return
@@ -164,7 +166,7 @@ def index(self):
164166
<h1 style="background-color: #d6eaf8; border-radius:10px; color:black">🐞 Bugs</h1>
165167
<p><b>What is this?</b> This project uses a simple web
166168
server to report bugs (exceptions) in a running application.</p>
167-
<h6><a href="/json">Show raw JSON</a></h6>'''
169+
<h6><a href="/json">Show raw JSON</a>&bul;<a href="/gotocommit">go to commit</a></h6>'''
168170

169171
if bugs_count:
170172
res+=f'<h2>😔 {bugs_count} bug(s) found</h2>'
@@ -187,4 +189,13 @@ def index(self):
187189
@cherrypy.expose
188190
@cherrypy.tools.json_out()
189191
def json(self):
190-
return get_data()
192+
return get_data()
193+
194+
@cherrypy.expose
195+
def gotocommit(self):
196+
import cherrypy
197+
if use_git:
198+
raise cherrypy.HTTPRedirect('/'.join((git_source,'tree',commit)))
199+
else:
200+
raise cherrypy.NotFound
201+

0 commit comments

Comments
 (0)