Skip to content

Update go 1.18 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}]
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ _testmain.go

pre-commit
main
build
build

.vscode/
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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+*
Expand All @@ -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:
Expand All @@ -35,19 +37,19 @@ $ git config --global core.hooksPath <path-to-global-hooks-folder>

### 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
```

Expand Down
4 changes: 2 additions & 2 deletions cmd/pre-commit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"path/filepath"
"time"

"github.com/ONSdigital/git-diff-check/diffcheck"
"github.com/necrophonic/git-diff-check/diffcheck"
)

const (
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions diffcheck/diffcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion diffcheck/diffcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions entropy/entropy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion entropy/entropy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"testing"

"github.com/ONSdigital/git-diff-check/entropy"
"github.com/necrophonic/git-diff-check/entropy"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/ONSdigital/git-diff-check
module github.com/necrophonic/git-diff-check

go 1.14
go 1.18
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion rule/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down