Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common/hooks: Prefill update info in commit msg #3489

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions common/Hooks/prepare-commit-msg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3
import argparse
import os
import subprocess
import yaml

scope_help = "# Scope and title, eg: nano: Update to 1.2.3\n"
help_msg = """
Expand All @@ -21,6 +23,15 @@

def commit_scope(commit_dir: str) -> str:
if os.path.exists(os.path.join(commit_dir, 'package.yml')):

recipe_diff_result = subprocess.run(['git', 'diff', '-U0', '--staged',
os.path.join(commit_dir, 'package.yml')],
stdout=subprocess.PIPE)
if "+version" in recipe_diff_result.stdout.decode('utf-8'):
with open(os.path.join(commit_dir, 'package.yml')) as recipe:
version = yaml.safe_load(recipe)['version']
return os.path.basename(commit_dir) + ': Update to ' + str(version)

return os.path.basename(commit_dir) + ': '

return ''
Expand Down
Loading