diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 23e46fc..5f1b74d 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -6,7 +6,7 @@ jobs: unit-test: strategy: matrix: - go: ["1.11", "1.12", "1.13", "1.14"] + go: ['1.18'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} name: Go ${{ matrix.go }} [${{ matrix.platform }}] diff --git a/.gitignore b/.gitignore index 2920fce..39785d5 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,6 @@ _testmain.go pre-commit main -build \ No newline at end of file +build + +.vscode/ diff --git a/CHANGELOG.md b/CHANGELOG.md index b9a6e04..61e942e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,9 @@ ## 0.5.0 2018-09-17 -- fix [#8](https://github.com/ONSdigital/git-diff-check/issues/8) ignore lines in a patch that are being removed rather than added / changed +- fix [#8](https://github.com/necrophonic/git-diff-check/issues/8) ignore lines in a patch that are being removed rather than added / changed - adds `-version` option to display the current cli version -- fix [#13](https://github.com/ONSdigital/git-diff-check/issues/13) add basic version check +- fix [#13](https://github.com/necrophonic/git-diff-check/issues/13) add basic version check ## 0.4.0 2018-04-25 diff --git a/README.md b/README.md index 758b432..0132f5a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ A simple library for checking git diff output for potentially sensitive information +(forked from my original at `ONSdigital/git-diff-check`) + ## Pre-commit hook *Requires git 2.9+* @@ -19,12 +21,12 @@ to test changes before you commit. 1. Run the installer: ```sh -$ curl -L https://raw.githubusercontent.com/ONSdigital/git-diff-check/master/install.sh | sh +$ curl -L https://raw.githubusercontent.com/necrophonic/git-diff-check/master/install.sh | sh ``` - **For other platforms** -1. Download the latest [release](https://github.com/ONSdigital/git-diff-check/releases) for your platform +1. Download the latest [release](https://github.com/necrophonic/git-diff-check/releases) for your platform 1. Create (if not already) a folder to store global git hooks (e.g. `${HOME}/.githooks`) 1. Unzip the release and place the `pre-commit` script in the global hooks folder (ensure it's executable) 1. Configure git to use the hooks: @@ -35,19 +37,19 @@ $ git config --global core.hooksPath ### From Source -(requires Go 1.11+) +(requires Go 1.18+) ```sh -$ go get github.com/ONSdigital/git-diff-check +$ go get github.com/necrophonic/git-diff-check # or .. $ cd ${GOPATH} -$ git clone https://github.com/ONSdigital/git-diff-check.git src/github.com/ONSdigital/git-diff-check +$ git clone https://github.com/necrophonic/git-diff-check.git src/github.com/necrophonic/git-diff-check ``` Then build: ```sh -$ cd ${GOPATH}/src/github.com/ONSdigital/git-diff-check +$ cd ${GOPATH}/src/github.com/necrophonic/git-diff-check $ go build -o pre-commit cmd/pre-commit/main.go ``` diff --git a/cmd/pre-commit/main.go b/cmd/pre-commit/main.go index 1c47be0..de0cc30 100644 --- a/cmd/pre-commit/main.go +++ b/cmd/pre-commit/main.go @@ -13,7 +13,7 @@ import ( "path/filepath" "time" - "github.com/ONSdigital/git-diff-check/diffcheck" + "github.com/necrophonic/git-diff-check/diffcheck" ) const ( @@ -24,7 +24,7 @@ const ( const ( // Repository defines the github repo where the source code is located - Repository = "ONSdigital/git-diff-check" + Repository = "necrophonic/git-diff-check" // LatestVersion gives the api location of the most recent tag in github LatestVersion = "https://api.github.com/repos/" + Repository + "/releases/latest" diff --git a/diffcheck/diffcheck.go b/diffcheck/diffcheck.go index e6f4321..57931bc 100644 --- a/diffcheck/diffcheck.go +++ b/diffcheck/diffcheck.go @@ -11,8 +11,8 @@ import ( "strconv" "strings" - "github.com/ONSdigital/git-diff-check/entropy" - "github.com/ONSdigital/git-diff-check/rule" + "github.com/necrophonic/git-diff-check/entropy" + "github.com/necrophonic/git-diff-check/rule" ) type ( diff --git a/diffcheck/diffcheck_test.go b/diffcheck/diffcheck_test.go index 5ba826a..1e19054 100644 --- a/diffcheck/diffcheck_test.go +++ b/diffcheck/diffcheck_test.go @@ -5,7 +5,7 @@ import ( "os/exec" "testing" - "github.com/ONSdigital/git-diff-check/diffcheck" + "github.com/necrophonic/git-diff-check/diffcheck" ) type testCase struct { diff --git a/entropy/entropy.go b/entropy/entropy.go index 980a227..8c9ae0e 100644 --- a/entropy/entropy.go +++ b/entropy/entropy.go @@ -26,8 +26,12 @@ func CalculateShannon(data []byte) float64 { } entropy := 0.0 pX := 0.0 - for x := 0; x < 256; x++ { - pX = float64(bytes.Count(data, []byte(string(x)))) / float64(len(data)) + + var start int32 = 0 + var end int32 = 255 + + for x := start; x <= end; x++ { + pX = float64(bytes.Count(data, []byte{byte(x)})) / float64(len(data)) if pX > 0 { entropy += -pX * math.Log2(pX) } diff --git a/entropy/entropy_test.go b/entropy/entropy_test.go index 675b202..a974027 100644 --- a/entropy/entropy_test.go +++ b/entropy/entropy_test.go @@ -9,7 +9,7 @@ import ( "fmt" "testing" - "github.com/ONSdigital/git-diff-check/entropy" + "github.com/necrophonic/git-diff-check/entropy" ) var ( diff --git a/go.mod b/go.mod index 472198a..36c09d2 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/ONSdigital/git-diff-check +module github.com/necrophonic/git-diff-check -go 1.14 +go 1.18 diff --git a/install.sh b/install.sh index 4830195..649e3e9 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -repo='ONSdigital/git-diff-check' +repo='necrophonic/git-diff-check' binary='pre-commit' get_latest_release() { # From https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c diff --git a/rule/rule_test.go b/rule/rule_test.go index 4714923..9e9a849 100644 --- a/rule/rule_test.go +++ b/rule/rule_test.go @@ -3,7 +3,7 @@ package rule_test import ( "testing" - "github.com/ONSdigital/git-diff-check/rule" + "github.com/necrophonic/git-diff-check/rule" ) func TestInitRules(t *testing.T) {