@@ -127,7 +127,7 @@ def is_sha(rev):
127
127
128
128
return len (rev ) == 40
129
129
130
- def is_impostor (repo , rev ):
130
+ def is_valid_rev (repo , rev , check_impostor ):
131
131
132
132
def compare (base , head ):
133
133
try :
@@ -138,32 +138,29 @@ def compare(base, head):
138
138
log (f"No common ancestor between { base } and { head } " )
139
139
return False
140
140
else :
141
- log (f'compare: GithubException: { e } ' )
141
+ log (f'check_rev: compare: GithubException: { e } ' )
142
142
raise
143
- return c .status in ('behind' , 'identical' )
143
+ status_ok = ('behind' , 'identical' ) if is_sha (head ) else ('identical' )
144
+ return c .status in status_ok
144
145
145
146
if not rev :
146
- log ('is_impostor: revision is None' )
147
- return True
148
-
149
- if not is_sha (rev ):
150
- log ('is_impostor: not a SHA' )
147
+ log ('check_rev: rev is None' )
151
148
return False
152
149
153
150
try :
154
151
for b in repo .get_branches ():
155
152
if compare (f'refs/heads/{ b .name } ' , rev ):
156
- log (f'Found revision { rev } in branch { b .name } ' )
157
- return False
153
+ log (f'check_rev: Found revision { rev } in branch { b .name } ' )
154
+ return True
158
155
for t in repo .get_tags ():
159
156
if compare (f'refs/tags/{ t .name } ' , rev ):
160
- log (f'Found revision { rev } in tag { t .name } ' )
161
- return False
157
+ log (f'check_rev: Found revision { rev } in tag { t .name } ' )
158
+ return True
162
159
except GithubException as e :
163
- log (f'is_impostor : GithubException: { e } ' )
164
- return True
160
+ log (f'check_rev : GithubException: { e } ' )
161
+ return False
165
162
166
- return True
163
+ return False
167
164
168
165
def fmt_rev (repo , rev ):
169
166
if not rev :
0 commit comments