|
14 | 14 | # #!/bin/sh |
15 | 15 | # python3 .githooks/post-commit.py |
16 | 16 | # ``` |
| 17 | +# |
| 18 | +# also add the following line to your ".git/config" to avoid |
| 19 | +# merge conflicts on amending the commit during a merge or rebase |
| 20 | +# |
| 21 | +# ```sh |
| 22 | +# git config --local merge.ours.driver true |
| 23 | +# ``` |
17 | 24 |
|
18 | 25 | from datetime import datetime |
19 | 26 | import os |
20 | 27 | import re |
21 | 28 | import subprocess |
22 | 29 |
|
23 | | -def is_special_git_operation(): |
24 | | - git_dir = subprocess.check_output(['git', 'rev-parse', '--git-dir'], universal_newlines=True).strip() |
25 | | - indicators = [ |
26 | | - os.path.join(git_dir, 'rebase-merge'), |
27 | | - os.path.join(git_dir, 'rebase-apply'), |
28 | | - os.path.join(git_dir, 'CHERRY_PICK_HEAD'), |
29 | | - os.path.join(git_dir, 'MERGE_HEAD'), |
30 | | - os.path.join(git_dir, 'BISECT_LOG'), |
31 | | - os.path.join(git_dir, 'REVERT_HEAD'), |
32 | | - ] |
33 | | - return any(os.path.exists(ind) for ind in indicators) |
34 | | - |
35 | 30 | def update_version(script_name, log_file, time, repo_name): |
36 | | - if is_special_git_operation(): |
37 | | - print(f'{time}: {repo_name} - {script_name} - Skipping during rebase/cherry-pick/merge', file=open(log_file, "a")) |
38 | | - return |
39 | | - |
40 | 31 | file_path = 'layouts/partials/version.txt' |
41 | 32 | try: |
42 | 33 | f = open(file_path, 'r+') |
|
0 commit comments