kopia lustrzana https://github.com/OpenDroneMap/ODM
Merge pull request #132 from xxfelixxx/patch-2
Add pre-commit hook and script to check that ccd_defs.json compilespull/156/merge
commit
57b3bfe3e3
15
README.md
15
README.md
|
@ -120,5 +120,18 @@ This problem is easily remedied. We need to know CCD size in the camera. We'll g
|
|||
So, we'll add the following line to our ccd_defs.json:
|
||||
|
||||
"SONY DSC-HX5V": 6.104,
|
||||
|
||||
|
||||
To check that ccd_defs.json compiles, run ccd_defs_check.pl
|
||||
If it prints the message 'CCD_DEFS compiles OK', then you can commit your changes.
|
||||
|
||||
And so others can use it, we'll do a pull request to add it to our array for everyone else.
|
||||
|
||||
---
|
||||
|
||||
Maintainers can run the ccd_defs.json compilation test automatically by creating a
|
||||
symbolic link in .git/hooks to hooks/pre-commit
|
||||
|
||||
cd .git/hooks
|
||||
ln -s ../../hooks/pre-commit
|
||||
|
||||
If ccd_defs.json does not compile, then the pre-commit hook will abort the commit.
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
|
||||
use File::Basename qw( dirname );
|
||||
use File::Spec;
|
||||
use JSON;
|
||||
|
||||
my $dir = dirname($0);
|
||||
my $ccd_defs = File::Spec->catfile($dir, 'ccd_defs.json');
|
||||
|
||||
open my $fh, $ccd_defs
|
||||
or die "Unable to open $ccd_defs : $!";
|
||||
local $/;
|
||||
my $json = <$fh>; # Slurp
|
||||
close $fh;
|
||||
|
||||
decode_json($json);
|
||||
print "CCD_DEFS compiles OK\n";
|
||||
exit 0;
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
exec 1>&2
|
||||
|
||||
echo "RUNNING PRE-COMMIT"
|
||||
|
||||
# Get list of files about to be committed
|
||||
if git diff --cached --name-only --diff-filter=ACM | grep 'ccd_defs.json'; then
|
||||
echo "We changed ccd_defs.json"
|
||||
GIT_ROOT=$(git rev-parse --show-toplevel)
|
||||
perl $GIT_ROOT/ccd_defs_check.pl
|
||||
fi
|
||||
|
||||
# non-zero exit fails the commit
|
||||
exit 0
|
Ładowanie…
Reference in New Issue