66import sys
77
88commit = None
9+ short_commit = None
910git_source = None
1011bugs = dict ()
1112build_state = 'passing'
@@ -26,6 +27,7 @@ def quick_config(file_path_ = 'bugs.json', use_git_=True, git_='git', git_source
2627def 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
5557def 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