File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,6 +107,19 @@ def get_branch():
107107 return _get_output ('git branch' ).split ()[- 1 ]
108108
109109
110+ def get_text_file_content (filename ):
111+ '''Get content of a text file
112+
113+ Locally (ie. non-github event) we return the content of the staged file,
114+ not the file in the working directory.
115+ '''
116+ if _is_github_event ():
117+ data = Path (filename ).read_text ()
118+ else :
119+ data = _get_output (f'git show :{ filename } ' )
120+ return data
121+
122+
110123def get_sha ():
111124 '''Get the commit sha
112125
@@ -738,9 +751,9 @@ def get_file_content(filename):
738751 # NOTE: ignored_patterns not implemented
739752
740753 try :
741- data = Path (filename ). read_text ( )
754+ data = get_text_file_content (filename )
742755 except Exception as exc :
743- print (f'Error { exc } : reading { filename } ' )
756+ print (f'Error " { exc } " while reading { filename } ' )
744757 return
745758
746759 # Skip binary file
You can’t perform that action at this time.
0 commit comments