def get_base_commit_sha(self, pull_request: PullRequest) -> Optional[str]: if self._settings.pull_request_build == pull_request_build_mode_merge: if self._settings.event: # for pull request events we take the other parent of the merge commit (base) if self._settings.event_name == 'pull_request': return self._settings.event.get('pull_request', {}).get('base', {}).get('sha') # for workflow run events we should take the same as for pull request events, # but we have no way to figure out the actual merge commit and its parents # we do not take the base sha from pull_request as it is not immutable if self._settings.event_name == 'workflow_run': return None try: # we always fall back to where the branch merged off base ref logger.debug( f'comparing {pull_request.base.ref} with {self._settings.commit}' ) compare = self._repo.compare(pull_request.base.ref, self._settings.commit) return compare.merge_base_commit.sha except: logger.warning(f'could not find best common ancestor ' f'between base {pull_request.base.sha} ' f'and commit {self._settings.commit}') return None
def warning(self, message: str, file: Optional[str] = None, line: Optional[int] = None, column: Optional[int] = None) -> str: logger.warning(message) params = {} if file is not None: params.update(file=file) if line is not None: params.update(line=line) if column is not None: params.update(col=column) return self._command(self._file, 'warning', message, params)