From a91f5dcdfc0db9de9b1ba69c35a9780ed2675abd Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Mon, 6 Feb 2023 14:42:37 +0000 Subject: [PATCH] use --short flag on git rev-parse --- Makefile | 2 +- notes2web.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1b77e0f..9b9e26f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ install: cp n2w_add_uuid.py /usr/local/bin - sed "s/N2W_COMMIT = \"\"/N2W_COMMIT = \"$$(git rev-parse HEAD)\"/" notes2web.py > /usr/local/bin/notes2web.py + sed "s/N2W_COMMIT = \"\"/N2W_COMMIT = \"$$(git rev-parse --short HEAD)\"/" notes2web.py > /usr/local/bin/notes2web.py pip3 install -r requirements.txt mkdir -p /opt/notes2web cp -r templates /opt/notes2web diff --git a/notes2web.py b/notes2web.py index 372097e..31846fc 100755 --- a/notes2web.py +++ b/notes2web.py @@ -22,8 +22,6 @@ INDEX_TEMPLATE_HEAD = None EXTRA_INDEX_CONTENT = None N2W_COMMIT = "" -# how many characters of a commit to show on landing page -COMMIT_SHA1_NCHARS = 7 def is_plaintext(filename): @@ -71,7 +69,7 @@ def get_inherited_tags(file, base_folder): def git_head_sha1(working_dir): git_response = subprocess.run( - [ 'git', f"--git-dir={working_dir.joinpath('.git')}", 'rev-parse', 'HEAD' ], + [ 'git', f"--git-dir={working_dir.joinpath('.git')}", 'rev-parse', '--short', 'HEAD' ], stdout=subprocess.PIPE ).stdout.decode('utf-8') @@ -405,8 +403,8 @@ def main(args): with open(args.home_index) as fp2: html = re.sub(r'\$title\$', args.output_dir.parts[0], fp2.read()) html = re.sub(r'\$h1title\$', args.output_dir.parts[0], html) - html = re.sub(r'\$n2w_commit\$', N2W_COMMIT[0:COMMIT_SHA1_NCHARS], html) - html = re.sub(r'\$notes_git_head_sha1\$', git_head_sha1(args.notes)[0:COMMIT_SHA1_NCHARS], html) + html = re.sub(r'\$n2w_commit\$', N2W_COMMIT, html) + html = re.sub(r'\$notes_git_head_sha1\$', git_head_sha1(args.notes), html) html = re.sub(r'\$data\$', json.dumps(all_entries), html)