Skip to content

Commit 0179439

Browse files
committed
update 5 shell scripts
1 parent 78245b5 commit 0179439

5 files changed

Lines changed: 25 additions & 21 deletions

File tree

shell/autofill-hook.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#!/usr/bin/env bash
2-
# CLI test.
2+
# CLI test for autofill hook.
33
#
44
# This script is *not* ready to be used in other projects. See shell/README.md
55
# for dev notes.
66
#
7-
# This is a pure CLI that script bypasses using VS Code or an extension. It will
8-
# get output from git, send it to Node CLI entry-point tool and print it. This
9-
# can be used as part of git commit message hook flow.
7+
# This is a pure CLIhat script that bypasses using VS Code or an extension.
8+
# It will get output from git, send it to Node CLI entry-point tool and print
9+
# it. This can be used as part of Git commit message hook flow.
1010
#
1111
# Optionally add a `-d` debug flag to print without writing to a file. This
12-
# makes it easy to debug the script outside a git commit hook flow.
12+
# makes it easy to debug the script outside a Git commit hook flow.
1313
# ./autofill-hook.sh -p
1414
#
1515
# See shell/README.md doc.
16-
1716
set -e
1817

1918
COMMIT_MSG_FILE=$1

shell/autofill.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
# Autofill script.
33
#
44
# Produce a commit message from changed files and print to stdout.
5-
5+
#
66
# This works similar to a Git hook, but is intended to be used alone or in a Git
77
# alias.
88
#
99
# See shell/README.md doc.
10-
# See src/git/cli.ts for flags.
10+
# See src/git/cli.ts for details on flags. Note `--cached` can be added
11+
# if you want to use staged changes only.
1112
set -e
1213

13-
DIFF_FLAGS="--name-status --find-renames --find-copies --no-color --cached"
14+
DIFF_FLAGS='--name-status --find-renames --find-copies --no-color'
1415
CHANGES=$(git diff-index $DIFF_FLAGS HEAD)
1516

1617
# TODO: Make this a global bin path.

shell/count-files.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
# Proof of concept script to use Bash to produce report of file counts from git
33
# status.
44
#
5-
# Run this as a standalone report, not as a hook. If you use this as a hook, it
6-
# will print output in the console only not add to commit message
5+
# Run this as a standalone report, not for use as a hook.
6+
# If you use this as a hook, it will print output in the console only and
7+
# not add to commit message.
78
#
8-
# See simple-hook.sh script for how CHANGES
9-
# would get written out to a commit message file.
9+
# See simple-hook.sh script for how CHANGES would get written out to a commit
10+
# message file.
1011
#
1112
# This script will get count of files added, modified, deleted and renamed/moved
1213
# and output it. Note that modified and renamed/moved can both apply to the same
1314
# file.
14-
# This does not support C (copied).
15-
15+
# This does not support 'C' (copied).
16+
#
1617
# This report uses git status and passes it do the steps below to parse it.
1718
# A more flexible approach (for unit tests for example) would be for this
1819
# script to handle the status and call another script to do the parsing and
@@ -22,7 +23,8 @@
2223
# Status summary excluding untracked files using a flag.
2324
CHANGES=$(git status -s -uno --porcelain)
2425

25-
# Note quotes AND -n to preserve newlines so line count for grep, for start of lines works.
26+
# Note quotes AND -n to preserve newlines so line count for grep, for start
27+
# of lines works.
2628
FILES=$(echo -n "$CHANGES" | wc -l)
2729

2830
echo "All files changed: $FILES"

shell/sample.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ SHA1=$3
2222

2323
###
2424

25-
# Show files change.
26-
# (It will uncomment files changed in the message - which is maybe less
25+
# Show files changed.
26+
# (It will uncomment files changed in the message, which is maybe less
2727
# efficient than just running git status but this is what git comes with.)
2828
case "$COMMIT_SOURCE,$SHA1" in
2929
, | template,)

shell/simple-hook.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/sh
2-
# A minimal git commit hook.
2+
# A minimal Git commit hook.
33
#
44
# Usage:
55
# ./simple-hook.sh MSG SRC SHA [-d]
6+
#
67
# The last part is an optional non-standard flag, allowing this to be run
78
# directly without writing out.
89
#
@@ -12,7 +13,7 @@
1213
set -e
1314

1415
# These are the 3 standard prepare-commit-msg args as per the hooks example and
15-
# git hook docs.
16+
# Git hook docs.
1617
COMMIT_MSG_FILE=$1
1718
COMMIT_SOURCE=$2
1819
SHA1=$3
@@ -34,7 +35,8 @@ else
3435
echo "$MESSAGE" >$COMMIT_MSG_FILE
3536
fi
3637

37-
# There is a weird bug where the space before the first line goes missing, but not in the dry run output.
38+
# There is a weird bug where the space before the first line goes missing,
39+
# but not in the dry run output.
3840
#
3941
# This is a message inserted before your commit message
4042
# M docs/installation.md

0 commit comments

Comments
 (0)