Changeset 293318 in webkit
- Timestamp:
- Apr 25, 2022, 12:57:24 AM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/hooks/prepare-commit-msg (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r293296 r293318 1 2022-04-16 Philippe Normand <philn@igalia.com> 2 3 [git] Allow pre-commit hook to feed from staged ChangeLogs 4 https://bugs.webkit.org/show_bug.cgi?id=239419 5 6 Reviewed by Jonathan Bedard. 7 8 In workflows where prepare-ChangeLog is executed manually before staging and committing 9 changes the prepare-commit-msg hook can now read the curated ChangeLog from the git stage 10 and present it in the editor for validation. In case no ChangeLog was staged, the hook will 11 generate a message itself. 12 13 * Scripts/hooks/prepare-commit-msg: 14 1 15 2022-04-23 Brady Eidson <beidson@apple.com> 2 16 -
trunk/Tools/Scripts/hooks/prepare-commit-msg
r289656 r293318 9 9 SCRIPTS = os.path.dirname(os.path.dirname(LOCATION)) 10 10 11 sys.path.append(SCRIPTS) 12 from webkitpy.common.checkout.diff_parser import DiffParser 13 14 def message_from_staged_changelogs(): 15 try: 16 diff = subprocess.check_output(['{{ git }}', 'diff', '--staged']) 17 except subprocess.CalledProcessError: 18 return '' 19 20 modified_files = DiffParser(diff.splitlines()).files 21 message = '' 22 for path, parsed_diff in modified_files.items(): 23 if not path.endswith('ChangeLog'): 24 continue 25 26 # Ignore first line (date, name, email) and second line (empty). 27 diff_lines = parsed_diff.lines[2:] 28 29 # Get added lines and strip leading 8 characters indentation. 30 lines = [line[2][SPACING:] for line in diff_lines if not line[0]] 31 32 message += '\n'.join(lines) 33 34 return message 11 35 12 36 def message(source=None, sha=None): 37 msg = message_from_staged_changelogs() 38 if msg: 39 return msg 40 13 41 dirname = None 14 42 commit_message = []
Note:
See TracChangeset
for help on using the changeset viewer.