Skip to content

Commit

Permalink
Write commit message to local cache.
Browse files Browse the repository at this point in the history
Signed-off-by: format 2020.01.12 <github.com/ChrisCummins/format>

[Exported from 6f77cd82ffc80c2814574d6ad9455e0c0a419daf]
  • Loading branch information
ChrisCummins committed Jan 12, 2020
1 parent ac4e0ee commit 22f2240
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tools/format/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def Main(argv):
print("\n".join(sorted(formatters.keys())))
return
elif FLAGS.install_pre_commit_hook:
git_util.InstallPreCommitHookOrDie()
git_util.InstallPreCommitHookOrDie(cache_dir)
return

# Acquire an inter-process lock. This does not need to be released - cleanup
Expand Down
8 changes: 4 additions & 4 deletions tools/format/git_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def GitAddOrDie(paths: Iterable[pathlib.Path]):
sys.exit(1)


def InstallPreCommitHookOrDie():
def InstallPreCommitHookOrDie(cache_path: pathlib.Path):
git_root = GetGitRootOrDie()

hooks_dir = git_root / ".git" / "hooks"
Expand Down Expand Up @@ -121,10 +121,10 @@ def InstallPreCommitHookOrDie():
f.write(
f"""\
#!/usr/bin/env bash
cp $1 /tmp/format_pre_commit_message.txt
cp $1 {cache_path / 'git_commit_message.txt'}
echo -e "\\n\\nSigned-off-by: format {version} <github.com/ChrisCummins/format>" > $1
cat /tmp/format_pre_commit_message.txt >> $1
rm -f /tmp/format_pre_commit_message.txt
cat {cache_path / 'git_commit_message.txt'} >> $1
rm -f {cache_path / 'git_commit_message.txt'}
"""
)
os.chmod(prepare_commit_msg, 0o744)
Expand Down

0 comments on commit 22f2240

Please sign in to comment.