Skip to content

Commit

Permalink
Merge pull request #64 from vbatts/mage
Browse files Browse the repository at this point in the history
Housekeeping!
  • Loading branch information
vbatts authored Mar 26, 2023
2 parents 3cdf99b + e445084 commit 58175ba
Show file tree
Hide file tree
Showing 420 changed files with 186 additions and 214,713 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.15', '1.16', '1.17', '1.18', '1.19', '1.20']
go: ['1.17', '1.18', '1.19', '1.20']

name: build and vet
steps:
Expand All @@ -29,7 +29,4 @@ jobs:
set -x
export PATH=$GOPATH/bin:$PATH
cd go/src/github.com/vbatts/tar-split
go test -v ./...
go vet -v ./...
go build -v ./...
#go run mage.go -v vet build test
go run mage.go -v vet build test
5 changes: 1 addition & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ jobs:
GOPATH: /home/runner/work/tar-split/tar-split/go
run: |
set -x
#curl -sSL https://github.com/magefile/mage/releases/download/v1.14.0/mage_1.14.0_Linux-64bit.tar.gz | tar -xzv mage && mv mage $GOPATH/bin/
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
export PATH=$GOPATH/bin:$PATH
cd go/src/github.com/vbatts/tar-split
golangci-lint run
#go run mage.go -v lint
go run mage.go -v lint
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Pristinely disassembling a tar archive, and stashing needed raw bytes and offset

Code API for libraries provided by `tar-split`:

* https://godoc.org/github.com/vbatts/tar-split/tar/asm
* https://godoc.org/github.com/vbatts/tar-split/tar/storage
* https://godoc.org/github.com/vbatts/tar-split/archive/tar
* [github.com/vbatts/tar-split/tar/asm](https://pkg.go.dev/github.com/vbatts/tar-split/tar/asm)
* [github.com/vbatts/tar-split/tar/storage](https://pkg.go.dev/github.com/vbatts/tar-split/tar/storage)
* [github.com/vbatts/tar-split/archive/tar](https://pkg.go.dev/github.com/vbatts/tar-split/archive/tar)

## Install

Expand Down
5 changes: 3 additions & 2 deletions cmd/tar-split/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (

"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/vbatts/tar-split/version"
)

var Version = "v0.11.3"

func main() {
app := cli.NewApp()
app.Name = "tar-split"
app.Usage = "tar assembly and disassembly utility"
app.Version = version.VERSION
app.Version = Version
app.Author = "Vincent Batts"
app.Email = "vbatts@hashbangbash.com"
app.Action = cli.ShowAppHelp
Expand Down
14 changes: 11 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
module github.com/vbatts/tar-split

go 1.15

require golang.org/x/sys v0.0.0-20220906165534-d0df966e6959 // indirect
go 1.17

require (
github.com/fatih/color v1.15.0
github.com/magefile/mage v1.14.0
github.com/sirupsen/logrus v1.9.0
github.com/urfave/cli v1.22.12
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
)
15 changes: 12 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo=
github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
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/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
Expand All @@ -21,9 +30,9 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/urfave/cli v1.22.12 h1:igJgVw1JdKH+trcLWLeLwZjU9fEfPesQ+9/e4MQ44S8=
github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959 h1:qSa+Hg9oBe6UJXrznE+yYvW51V9UbyIj/nj/KpDigo8=
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
10 changes: 10 additions & 0 deletions mage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// +build ignore

package main

import (
"os"
"github.com/magefile/mage/mage"
)

func main() { os.Exit(mage.Main()) }
28 changes: 28 additions & 0 deletions mage_color.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build mage
// +build mage

package main

import (
"io"
"os"

"github.com/fatih/color"
)

var (
ourStdout = cw{c: color.New(color.FgGreen), o: os.Stdout}
ourStderr = cw{c: color.New(color.FgRed), o: os.Stderr}
)

// hack around color.Color not implementing Write()
type cw struct {
c *color.Color
o io.Writer
}

func (cw cw) Write(p []byte) (int, error) {
i := len(p)
_, err := cw.c.Fprint(cw.o, string(p)) // discarding the number of bytes written for now...
return i, err
}
116 changes: 116 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
//go:build mage
// +build mage

package main

import (
"fmt"
"os"
"os/exec"

"github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps
)

var (
// Default target to run when none is specified
// If not set, running mage will list available targets
Default = Build
app string = "tar-split"
Stdout = ourStdout
Stderr = ourStderr

golangcilintVersion = "v1.51.2"
)

// Run all-the-things
func All() error {
mg.Deps(Vet)
mg.Deps(Test)
mg.Deps(Build)
mg.Deps(Lint)
return nil
}

// A build step that requires additional params, or platform specific steps for example
func Build() error {
mg.Deps(InstallDeps)
fmt.Println("Building...")
cmd := exec.Command("go", "build", "-v", "-o", app, "./cmd/tar-split")
cmd.Stdout = Stdout
cmd.Stderr = Stderr
return cmd.Run()
}

// Vet the codes
func Vet() error {
fmt.Println("go vet...")
cmd := exec.Command("go", "vet", "./...")
cmd.Stdout = Stdout
cmd.Stderr = Stderr
return cmd.Run()
}

// Run the Linters
func Lint() error {
mg.Deps(InstallToolsLint)
fmt.Println("Linting...")
cmd := exec.Command("golangci-lint", "run")
cmd.Stdout = Stdout
cmd.Stderr = Stderr
return cmd.Run()
}

// Run the tests available
func Test() error {
fmt.Println("Testing...")
cmd := exec.Command("go", "test", "-v", "./...")
cmd.Stdout = Stdout
cmd.Stderr = Stderr
return cmd.Run()
}

// A custom install step if you need your bin someplace other than go/bin
func Install() error {
mg.Deps(Build)
fmt.Println("Installing...")
return os.Rename(app, "/usr/local/bin/"+app)
}

// Manage your deps, or running package managers.
func InstallDeps() error {
mg.Deps(Tidy)
fmt.Println("Installing Deps...")
cmd := exec.Command("go", "get", "./...")
cmd.Stdout = Stdout
cmd.Stderr = Stderr
return cmd.Run()
}

// Tools used during build/dev/test
func InstallTools() error {
mg.Deps(InstallToolsLint)
return nil
}

func InstallToolsLint() error {
fmt.Println("Installing Deps...")
cmd := exec.Command("go", "install", "github.com/golangci/golangci-lint/cmd/golangci-lint@"+golangcilintVersion)
cmd.Stdout = Stdout
cmd.Stderr = Stderr
return cmd.Run()
}

// Tidy go modules
func Tidy() error {
fmt.Println("Tidy up...")
cmd := exec.Command("go", "mod", "tidy")
cmd.Stdout = Stdout
cmd.Stderr = Stderr
return cmd.Run()
}

// Clean up after yourself
func Clean() {
fmt.Println("Cleaning...")
os.RemoveAll(app)
}
17 changes: 0 additions & 17 deletions tar/storage/packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ type Unpacker interface {
Next() (*Entry, error)
}

/* TODO(vbatts) figure out a good model for this
type PackUnpacker interface {
Packer
Unpacker
}
*/

type jsonUnpacker struct {
seen seenNames
dec *json.Decoder
Expand Down Expand Up @@ -115,13 +108,3 @@ func NewJSONPacker(w io.Writer) Packer {
seen: seenNames{},
}
}

/*
TODO(vbatts) perhaps have a more compact packer/unpacker, maybe using msgapck
(https://github.com/ugorji/go)
Even though, since our jsonUnpacker and jsonPacker just take
io.Reader/io.Writer, then we can get away with passing them a
gzip.Reader/gzip.Writer
*/
21 changes: 0 additions & 21 deletions vendor/github.com/cpuguy83/go-md2man/v2/LICENSE.md

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go

This file was deleted.

Loading

0 comments on commit 58175ba

Please sign in to comment.