Skip to content

Files that aren't in the commit are searched for commit comments #1

Description

@SonOfLilit
$ git commit
.git/hooks/prepare-commit-msg: line 43: conditional binary operator expected
.git/hooks/prepare-commit-msg: line 43: syntax error near `=~'
.git/hooks/prepare-commit-msg: line 43: `  if [[ "${IGNORED[*]}" =~ "${filename}" || "${IGNORED[*]}" =~ "${extension}" ]]; then'

$ cd ../commit-comments/
$ git log | head -n 1
commit a916600e8cc2b0cb0f6da2533d616da3ddca5f68

$ /bin/bash --version
GNU bash, version 3.1.20(4)-release (i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.

Running

#!/bin/bash
ADDED_FILES=( $(git ls-files) )
echo $ADDED_FILES
echo '************'
for i in ${!ADDED_FILES[@]}; do
  file_path=${ADDED_FILES["$i"]}
  filename=$( basename "$file_path" )
  extension="${filename##*.}"
  echo $file_path
  echo $filename
  echo $extension
  if [[ "${IGNORED[*]}" =~ "${filename}" || "${IGNORED[*]}" =~ "${extension}" ]]; then
    # File should not be read - remove
    unset ADDED_FILES["$i"]
  fi
done

gives

$ . test.sh
.gitignore
************
sh.exe": ./test.sh: line 12: conditional binary operator expected
sh.exe": ./test.sh: line 12: syntax error near `=~'
sh.exe": ./test.sh: line 12: `  if [[ "${IGNORED[*]}" =~ "${filename}" || "${IGNORED[*]}" =~ "${extension}" ]]; then'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions