Sha256: 3fcc711c734eeaee4bc80c20a4bef83c1c9acaa8454c080162856cea2cf951db

Contents?: true

Size: 860 Bytes

Versions: 21

Compression:

Stored size: 860 Bytes

Contents

#!/usr/bin/env sh

repeat() {
  char="$1"
  times="$2"
  text=""
  i=0

  while [ $i -lt $times ]
  do
    text="${text}${char}"
    i=$((i+1))
  done
  echo "$text"
}

prevent_conflict_markers() {
  TERM="xterm-256color"
  RED=$(tput setab 1)
  NORMAL=$(tput sgr0)

  left_arrow=$(repeat '<' 7)
  right_arrow=$(repeat '>' 7)
  equal_symbol=$(repeat '=' 7)

  CONFLICT_MARKERS="${left_arrow}|${equal_symbol}|${right_arrow}"
  occurrences_count=$(git --no-pager diff --staged --ignore-blank-lines --name-only -G"$CONFLICT_MARKERS" | wc -l)
  if [ "$occurrences_count" -gt 0 ]
  then
    echo "$RED ERROR $NORMAL Found ${CONFLICT_MARKERS} symbols in staged files."
    echo "Conflict markers should be removed from the following files before committing:"
    git --no-pager diff --staged --ignore-blank-lines --name-only -G"$CONFLICT_MARKERS"
    exit 1;
  fi
}

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.89 lib/neeto_commons_backend/common_files/.husky/helpers/prevent_conflict_markers.sh