Skip to content

Commit b46f019

Browse files
committed
github: apply commit msg check to all commits
1 parent cfe12d8 commit b46f019

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

.github/automation/pr-title-check.py .github/automation/commit-msg-check.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# *******************************************************************************
44
# Copyright 2024 Arm Limited and affiliates.
5+
# Copyright 2024 Intel Corporation
56
# SPDX-License-Identifier: Apache-2.0
67
#
78
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +19,7 @@
1819
# *******************************************************************************
1920

2021
import argparse
21-
22+
import subprocess
2223

2324
# * Ensuring the scopes end in colon and same level scopes are comma delimited.
2425
# TODO: Limit scopes to an acceptable list of tags.
@@ -61,12 +62,20 @@ def __numCharacterCheck(msg: str):
6162

6263
def main():
6364
parser = argparse.ArgumentParser()
64-
parser.add_argument("msg", help="Commit message to check.")
65+
parser.add_argument("head", help="Head commit of PR branch")
66+
parser.add_argument("base", help="Base commit of PR branch")
6567
args = parser.parse_args()
66-
msg: str = args.msg
67-
print(f"msg: {msg}")
68-
__numCharacterCheck(msg)
69-
__scopeCheck(msg)
68+
base: str = args.base
69+
head: str = args.head
70+
71+
commit_range = base + ".." + head
72+
messages = subprocess.run(["git", "rev-list", "--ancestry-path", commit_range, "--format=oneline"], capture_output=True, text=True).stdout
73+
74+
for i in messages.splitlines():
75+
commit_msg=i.split(' ', 1)[1]
76+
print(f"msg: {commit_msg}")
77+
__numCharacterCheck(commit_msg)
78+
__scopeCheck(commit_msg)
7079

7180

7281
if __name__ == "__main__":

.github/workflows/pr-check.yml .github/workflows/commit-msg-check.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# *******************************************************************************
22
# Copyright 2024 Arm Limited and affiliates.
3+
# Copyright 2024 Intel Corporation
34
# SPDX-License-Identifier: Apache-2.0
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,8 +27,9 @@ permissions: read-all
2627

2728
jobs:
2829
title:
30+
if: github.repository == 'oneapi-src/oneDNN'
2931
runs-on: ubuntu-latest
3032
steps:
3133
- uses: actions/checkout@v4
32-
- name: Pass pull request title through script.
33-
run: python3 ./.github/automation/pr-title-check.py "${{ github.event.pull_request.title }}"
34+
- name: Pass pull request commit messages through script.
35+
run: python3 ./.github/automation/commit-msg-check.py "${{ github.event.pull_request.head }}" "${{ github.event.pull_request.base }}"

0 commit comments

Comments
 (0)