Skip to content

Commit

Permalink
Updated from main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbn committed Feb 14, 2023
2 parents 7aa917b + f94593e commit f50e6ca
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 79 deletions.
28 changes: 28 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file is for unifying the coding style for different editors and IDEs.
# More information at http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
indent_size = 2

[*.{yml,yaml}]
indent_size = 2

[*.json]
indent_size = 2

[*.go]
indent_style = tab

[*.mod]
indent_style = tab
File renamed without changes.
5 changes: 5 additions & 0 deletions .github/markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"root": true,
"MD004": { "style": "dash" },
"line-length": false
}
3 changes: 2 additions & 1 deletion renovate.json → .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
"config:base",
":disableDependencyDashboard"
],
"enabledManagers": ["pre-commit"]
}
2 changes: 1 addition & 1 deletion .spellcheck.yaml → .github/spellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matrix:
ignore-case: true
dictionary:
wordlists:
- .wordlist.txt
- .github/spellchecker-wordlist.txt
encoding: utf-8
pipeline:
- pyspelling.filters.markdown:
Expand Down
2 changes: 2 additions & 0 deletions .wordlist.txt → .github/spellchecker-wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ NONINFRINGEMENT
WIP
STDIN
stdin
fullpath
nofullpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: rojopolis/spellcheck-github-actions@0.28.0
- uses: rojopolis/spellcheck-github-actions@0.29.0
name: Spellcheck
with:
config_path: .github/spellcheck.yml # put path to configuration file here
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go
name: Go Build and Test Action

on:
push:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: goreleaser
name: Go Releaser Action

on:
push:
Expand All @@ -21,7 +21,7 @@ jobs:
go-version: 1.17
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ jobs:
name: Markdownlint
with:
files: .
config_file: ".markdownlint.json"
config_file: ".github/markdownlint.json"
ignore_path: ".github/.markdownlintignore"
9 changes: 0 additions & 9 deletions .markdownlint.json

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log for stevedore

## 0.7.0 2023-02-07 feature release, update not required

- Improved output so both full path and flattened list is available
- full path is the new default, can be explicitly requested using ^--fullpath`
- flat structure, can be explicitly requested using ^--nofullpath`

## 0.6.1 2022-11-22 Bug fix release, update not required

- Fixed bug in consumption of file from STDIN, the contents would only be partial
Expand Down
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# stevedore

`stevedore` is a small command line tool taking it's name from the worker working on the dock with loading cargo onto ships.
`stevedore` is a small command line tool taking it's name from the worker, working on the dock with loading cargo unto ships.

REF: [Wikipedia][WIKIPEDIA]

Expand All @@ -15,23 +15,23 @@ stevedore .
The above example

1. Locates the `.dockerignore` file
1. Reads the current directory (specified as `.`) recursively
1. Compares the located `.dockerignore` file with the contents of the specified directory and below
1. Outputs a more or less expressive and colourful report
2. Reads the current directory (specified as `.`) recursively
3. Compares the located `.dockerignore` file with the contents of the specified directory
4. Outputs a report

```text
. included
.dockerignore included
.gitignore included
README.md included
TODO included
go.mod included
go.sum included
main.go ignored
stevedore included
.
.dockerignore
.gitignore
README.md
TODO
go.mod
go.sum
main.go
stevedore
```

You can actually emit the path parameter, `stevedore` defaults to current directory.
You can actually emit the path parameter, since `stevedore` defaults to current directory.

## Parameters

Expand All @@ -47,6 +47,7 @@ Since this is just an analysis/reporting tool it can be fed with parameters to d
- `--excluded` emits only excluded files (ignored)
- `--invertcolors` inverts the used colors
- `--stdin` / `-s` reads ignore file from STDIN
- `--fullpath` / `-f` emits full path of encountered files and directories

### Verbosity

Expand All @@ -57,15 +58,15 @@ stevedore -verbose .
```

```text
path . not ignored and is included in Docker image
path .dockerignore not ignored and is included in Docker image
path .gitignore not ignored and is included in Docker image
path README.md not ignored and is included in Docker image
path TODO not ignored and is included in Docker image
path go.mod not ignored and is included in Docker image
path go.sum not ignored and is included in Docker image
path main.go ignored and is included in Docker image
path stevedore not ignored and is included in Docker image
path . is not ignored and is included in Docker image
path .dockerignore is not ignored and is included in Docker image
path .gitignore is not ignored and is included in Docker image
path README.md is not ignored and is included in Docker image
path TODO is not ignored and is included in Docker image
path go.mod is not ignored and is included in Docker image
path go.sum is not ignored and is included in Docker image
path main.go is ignored and is included in Docker image
path stevedore is not ignored and is included in Docker image
```

### Passing in a ignore file using either stdin and ignore file parameters
Expand All @@ -90,7 +91,7 @@ These will render the same result.

You can add an ignore file, named `.stevedoreignore` to your directory. It will tell `stevedore` what files and directories to ignore prior to making it's analysis.

Meaning that patterns in this file which are matched, will be excluded.
Meaning that patterns in this files matched, will be _excluded_.

The `.stevedoreignore` file follows the general implementation pattern. and example could be:

Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/jonasbn/stevedore
go 1.19

require (
github.com/fatih/color v1.13.0
github.com/fatih/color v1.14.1
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
)

require (
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
golang.org/x/sys v0.3.0 // indirect
)
21 changes: 10 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
60 changes: 36 additions & 24 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type config struct {
Excluded bool
Included bool
Invertcolors bool
Fullpath bool
Nofullpath bool
}

// main function is a wrapper on the realMain function and emits OS exit code based on wrapped function
Expand Down Expand Up @@ -57,10 +59,8 @@ func realMain() int {
fmt.Println("error unmarshalling JSON configuration:", err)
}

} else {
if config.Debug {
fmt.Println("No stevedore configuration file found")
}
} else if config.Debug {
fmt.Println("No stevedore configuration file found")
}

flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
Expand Down Expand Up @@ -91,6 +91,11 @@ func realMain() int {

flag.BoolVar(&config.Invertcolors, "invertcolors", false, "inverts the used color")

flag.BoolVar(&config.Fullpath, "fullpath", true, "emits files and directories with full path")
flag.BoolVar(&config.Fullpath, "f", true, "emits files and directories with full path")

flag.BoolVar(&config.Nofullpath, "nofullpath", false, "emits files and directories without full path")

nocolorEnv := os.Getenv("NO_COLOR")

flag.Parse()
Expand All @@ -111,7 +116,7 @@ func realMain() int {
// read line from stdin using newline as separator
line := scanner.Text()

//append the line to a slice
// append the line to a slice
lines = append(lines, line)
}
ignoreLines = strings.Join(lines, "\n")
Expand All @@ -122,15 +127,12 @@ func realMain() int {
fmt.Printf("ignorelines: \n%s\n\n", ignoreLines)
}

} else {

if config.Ignorefile == "" {
config.Ignorefile = path + "/.dockerignore"
} else if config.Ignorefile == "" {
config.Ignorefile = path + "/.dockerignore"

if debug {
fmt.Println("path: ", path)
fmt.Println("ignoreFile: ", config.Ignorefile)
}
if debug {
fmt.Println("path: ", path)
fmt.Println("ignoreFile: ", config.Ignorefile)
}
}

Expand All @@ -155,6 +157,8 @@ func realMain() int {
fmt.Println("verbose: ", config.Verbose)
fmt.Println("excluded: ", config.Excluded)
fmt.Println("included: ", config.Included)
fmt.Println("fullpath: ", config.Fullpath)
fmt.Println("nofullpath: ", config.Nofullpath)
fmt.Println("tail: ", flag.Args())
fmt.Println("ENV: ", nocolorEnv)
}
Expand All @@ -179,9 +183,11 @@ func realMain() int {
}

if config.Invertcolors {
tmpColor := ignoredColor
ignoredColor = includedColor
includedColor = tmpColor
ignoredColor, includedColor = includedColor, ignoredColor
}

if config.Nofullpath {
config.Fullpath = false
}

var err error
Expand All @@ -201,10 +207,8 @@ func realMain() int {
ownIgnoreObject = ignore.CompileIgnoreLines([]string{}...)
}

} else {
if debug {
fmt.Println("No stevedore ignorefile found")
}
} else if debug {
fmt.Println("No stevedore ignorefile found")
}

err = filepath.Walk(path, func(path string, info fs.FileInfo, err error) error {
Expand All @@ -224,15 +228,23 @@ func realMain() int {
return nil
}

var entry string

if config.Fullpath {
entry = path
} else {
entry = info.Name()
}

if ignoreObject.MatchesPath(path) {
if config.Excluded {
if config.Color {
color.Set(ignoredColor)
}
if config.Verbose {
fmt.Printf("path %s ignored and is not included in Docker image\n", info.Name())
fmt.Printf("path %s ignored and is not included in Docker image\n", entry)
} else {
fmt.Printf("%s\n", info.Name())
fmt.Printf("%s\n", entry)
}
color.Unset()
}
Expand All @@ -242,9 +254,9 @@ func realMain() int {
color.Set(includedColor)
}
if config.Verbose {
fmt.Printf("path %s not ignored and is included in Docker image\n", info.Name())
fmt.Printf("path %s not ignored and is included in Docker image\n", entry)
} else {
fmt.Printf("%s\n", info.Name())
fmt.Printf("%s\n", entry)
}
color.Unset()
}
Expand Down
Loading

0 comments on commit f50e6ca

Please sign in to comment.