File tree Expand file tree Collapse file tree 4 files changed +64
-0
lines changed
Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 252252 "script:name" : " test -f ./scripts/package_app_name.js && node --experimental-modules --no-warnings --no-deprecation ./scripts/package_app_name.js || echo '✔ Node package name script is missing'" ,
253253 "script:notes" : " test -f ./scripts/git_release_notes.sh && . ./scripts/git_release_notes.sh > NOTES.md || echo '✔ Git release notes script is missing'" ,
254254 "script:size" : " test -f ./scripts/git_size.sh && . ./scripts/git_size.sh || echo '✔ Git size script is missing'" ,
255+ "script:conflict" : " test -f ./scripts/pre-commit.sh && /bin/bash ./scripts/pre-commit.sh || echo '✔ Git pre-commit script is missing'" ,
255256 "setheapsize" : " export NODE_OPTIONS=--max_old_space_size=2048" ,
256257 "solidarity" : " solidarity" ,
257258 "solidarity:update" : " solidarity snapshot cli node" ,
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # from https://github.com/pre-commit/pre-commit-hooks
3+ # and made more blunt
4+ from __future__ import print_function
5+
6+ import argparse
7+ import os .path
8+ import sys
9+
10+ CONFLICT_PATTERNS = [
11+ '<<<<<<< ' ,
12+ '======= ' ,
13+ '=======\n ' ,
14+ '>>>>>>> '
15+ ]
16+ WARNING_MSG = 'Merge conflict string "{0}" found in {1}:{2}'
17+
18+
19+ def detect_merge_conflict (argv = None ):
20+ parser = argparse .ArgumentParser ()
21+ parser .add_argument ('filenames' , nargs = '*' )
22+ args = parser .parse_args (argv )
23+
24+ retcode = 0
25+ for filename in args .filenames :
26+ with open (filename ) as inputfile :
27+ for i , line in enumerate (inputfile ):
28+ for pattern in CONFLICT_PATTERNS :
29+ if line .startswith (pattern ):
30+ print (WARNING_MSG .format (pattern , filename , i + 1 ))
31+ retcode = 1
32+
33+ return retcode
34+
35+ if __name__ == '__main__' :
36+ sys .exit (detect_merge_conflict ())
Original file line number Diff line number Diff line change 1515
1616# Usage example: /bin/sh ./scripts/hook.sh
1717
18+ set -o errexit
19+ set -o nounset
20+ set -o pipefail
21+
1822cat << EOF
1923Build specification:
2024 DefaultRepo: $SKAFFOLD_DEFAULT_REPO
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Copyright (C) 2022 SensibleMetrics, Inc. (http://sensiblemetrics.io/)
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+
16+ # Usage example: /bin/bash ./scripts/pre-commit.sh
17+
18+ set -o errexit
19+ set -o nounset
20+ set -o pipefail
21+
22+ # probably a dumb way to detect changed files which are not deleted
23+ scripts/check_merge_conflict.py $( comm -12 <( git diff --name-only --cached) <( git ls-files) )
You can’t perform that action at this time.
0 commit comments