Skip to content
Snippets Groups Projects
Commit 4b8f7768 authored by nimrod's avatar nimrod
Browse files

WIP.

parent 36d32375
Branches
Tags
No related merge requests found
- repo: https://github.com/pre-commit/pre-commit-hooks
sha: v0.7.1
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-yaml
- repo: https://www.shore.co.il/git/shell-pre-commit/
sha: v0.5.4
hooks:
- id: shell-lint
files: &shellscripts 'merge-conflict'
- id: shellcheck
files: *shellscripts
- repo: ./
sha: HEAD
hooks:
- id: merge-conflict
---
- id: merge-conflict
name: merge conflicts
description: Checks for merge conflicts to the master branch.
language: script
entry: merge-conflict
files: '$^'
always_run: True
---
language: python
python: "3.6"
dist: trusty
sudo: false
group: beta
cache:
- pip
- directories:
- $HOME/.pre-commit
- $HOME/.cabal
- $HOME/.ghc
addons:
apt:
packages:
- cabal-install
- ghc
env:
PATH: "$HOME/bats/bin:$HOME/.cabal/bin:$PATH"
install:
- cabal update && cabal install shellcheck
- pip install pre_commit | cat
- git clone --depth 1 https://github.com/sstephenson/bats.git "$HOME/bats"
script:
- pre-commit run --all-files
notifications:
on_failure: never
email: false
.pre-commit-hooks.yaml
\ No newline at end of file
#!/bin/sh
set -eu
dest="${1:-master}"
current="$(git symbolic-ref --short HEAD)"
[ "$current" != "$dest" ] || exit
git format-patch "$(git merge-base HEAD "$dest")..$dest" --stdout | git apply --check -
#!/usr/bin/env bats
export PATH="$BATS_TEST_DIRNAME/../:$PATH"
export repo="$BATS_TMPDIR/testrepo"
@test "setup" {
if [ ! -f "$repo/file" ]
then
git init "$repo"
cd "$repo"
echo 1 > file
git -C "$repo" add "$repo/file"
git -C "$repo" commit -m "Initial commit."
git -C "$repo" checkout -b master2
git -C "$repo" checkout -b no-conflict
git -C "$repo" checkout -b conflict
echo 2 > "$repo/file"
git -C "$repo" commit file -m "Conflict with master."
git -C "$repo" checkout master
echo 3 > "$repo/file"
git -C "$repo" commit file -m "Conflict with the conflict branch."
fi
}
@test "Same branch" {
cd "$repo"
git checkout master || true
merge-conflict
}
@test "No conflict" {
cd "$repo"
git checkout no-conflict || true
merge-conflict
}
@test "Different than master" {
cd "$repo"
git checkout master || true
merge-conflict master2
}
@test "Conflict" {
cd "$repo"
git checkout conflict || true
! merge-conflict
}
@test "teardown" {
rm -rf "$repo"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment