Skip to content

Commit

Permalink
Merge branch 'master' into project/pypdf
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarco authored Jul 10, 2023
2 parents 212c3a9 + c4e1361 commit feb5f9b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions infra/cifuzz/sarif_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,7 @@ def get_sarif_data(stacktrace, target_path):
def write_stacktrace_to_sarif(stacktrace, target_path, workspace):
"""Writes a description of the crash in stacktrace to a SARIF file."""
data = get_sarif_data(stacktrace, target_path)
if not os.path.exists(workspace.sarif):
os.makedirs(self.workspace.sarif)
with open(os.path.join(workspace.sarif, 'results.sarif'), 'w') as file_handle:
file_handle.write(json.dumps(data))
36 changes: 35 additions & 1 deletion infra/pr_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
BASE_URL = f'{API_URL}/repos/{OWNER}/{REPO}'
BRANCH = 'master'
CRITICALITY_SCORE_PATH = '/home/runner/go/bin/criticality_score'
COMMITS_LIMIT = 50 # Only process the most recent 50 commits.


def get_criticality_score(repo_url):
Expand Down Expand Up @@ -118,10 +119,15 @@ def main():
# Checks the previous commits.
commit_sha = github.has_author_modified_project(project_path)
if commit_sha is None:
history_message = ''
contributors = github.get_past_contributors(project_path)
if contributors:
history_message = 'The past contributors are: '
history_message += ', '.join(contributors)
message += (
f'{pr_author} is a new contributor to '
f'[{project_path}]({project_url}). The PR must be approved by known '
'contributors before it can be merged.<br/>')
f'contributors before it can be merged. {history_message}<br/>')
is_ready_for_merge = False
continue

Expand Down Expand Up @@ -223,6 +229,34 @@ def get_pull_request_number(self, commit):
return None
return pr_response.json()[0]['number']

def get_past_contributors(self, project_path):
"""Returns a list of past contributors of a certain project."""
commits_response = requests.get(f'{BASE_URL}/commits?path={project_path}',
headers=self._headers)

if not commits_response.ok:
return []
commits = commits_response.json()
contributors: dict[str, bool] = {}
for i, commit in enumerate(commits):
if i >= COMMITS_LIMIT:
break

login = commit['author']['login']
verified = commit['commit']['verification']['verified']
if login not in contributors:
contributors[login] = verified
if verified:
# Override previous verification bit.
contributors[login] = True

all_contributors = []
for login, verified in contributors.items():
login_verify = login if verified else f'{login} (unverified)'
all_contributors.append(login_verify)

return all_contributors

def is_author_internal_member(self):
"""Returns if the author is an internal member."""
response = requests.get(f'{BASE_URL}/contents/infra/MAINTAINERS.csv',
Expand Down

0 comments on commit feb5f9b

Please sign in to comment.