Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from KevinDeJong-TomTom/remove-need-for-checkout
Browse files Browse the repository at this point in the history
refactor: remove need to retrieve full repository history
  • Loading branch information
KevinDeJong-TomTom authored Sep 23, 2020
2 parents 47b16a2 + 84a031b commit aa8ef9e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/commisery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
steps:
- name: Check-out the repo under $GITHUB_WORKSPACE
uses: actions/checkout@v2
with:
# ensure we retrieve the full history as we need to check all commits in the provided Pull Request
fetch-depth: 0

- name: Run Commisery
uses: ./
Expand Down
3 changes: 0 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ The workflow, usually declared in `.github/workflows/build.yml`, looks like:
steps:
- name: Check-out the repo under $GITHUB_WORKSPACE
uses: actions/checkout@v2
with:
# ensure we retrieve the full history as we need to check all commits in the provided Pull Request
fetch-depth: 0
- name: Run Commisery
uses: KevinDeJong-TomTom/commisery-action@master
Expand Down
12 changes: 6 additions & 6 deletions commisery_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ def error_message(message: str):
print(f'::error ::{message}')


def create_pr_file(pull_request: object) -> str:
def message_to_file(message: str) -> str:
filename = 'commit_message'

f = open(filename, 'w+')
f.write(pull_request.title)
f.write(message)
f.close()

return filename


def check_message(argument: str) -> bool:
def check_message(message: str) -> bool:
proc = subprocess.Popen(
["commisery-verify-msg", argument],
["commisery-verify-msg", message_to_file(message)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
Expand All @@ -72,13 +72,13 @@ def main(token: str, repository: str, pull_request_id: int) -> int:
repo = Github(token).get_repo(repository)
pr = repo.get_pull(int(pull_request_id))

if not check_message(create_pr_file(pr)):
if not check_message(pr.title):
errors += 1

commits = pr.get_commits()

for commit in commits:
if not check_message(commit.sha):
if not check_message(commit.commit.message):
errors += 1

exit(1 if errors else 0)
Expand Down

0 comments on commit aa8ef9e

Please sign in to comment.