Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Chase improvements to input hashing in gps #97

Merged
merged 7 commits into from
Jan 19, 2017
Merged
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 analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ func (a analyzer) DeriveManifestAndLock(path string, n gps.ProjectRoot) (gps.Man

func (a analyzer) Info() (name string, version *semver.Version) {
v, _ := semver.NewVersion("v0.0.1")
return "example-analyzer", v
return "hoard", v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nest

}
1 change: 1 addition & 0 deletions ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (cmd *ensureCommand) Name() string { return "ensure" }
func (cmd *ensureCommand) Args() string { return "[spec...]" }
func (cmd *ensureCommand) ShortHelp() string { return ensureShortHelp }
func (cmd *ensureCommand) LongHelp() string { return ensureLongHelp }
func (cmd *ensureCommand) Hidden() bool { return false }

func (cmd *ensureCommand) Register(fs *flag.FlagSet) {
fs.BoolVar(&cmd.examples, "examples", false, "print detailed usage examples")
Expand Down
2 changes: 1 addition & 1 deletion ensure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func main() {

sysCommit := tg.getCommit("go.googlesource.com/sys")
expectedLock := `{
"memo": "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c",
"memo": "574170053fb14e0ecdd0ec4d8bb3323b901cb98710ac0da175efdf881dd4fb81",
"projects": [
{
"name": "github.com/Sirupsen/logrus",
Expand Down
57 changes: 57 additions & 0 deletions hash_in.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is missing the license header

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i fixed


import (
"flag"
"fmt"

"github.com/pkg/errors"
"github.com/sdboyer/gps"
)

func (cmd *hashinCommand) Name() string { return "hash-inputs" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait why do we need this command?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exclusively for debugging. i'm totally fine to pull it out if it seems like overkill to add it

func (cmd *hashinCommand) Args() string { return "" }
func (cmd *hashinCommand) ShortHelp() string { return "" }
func (cmd *hashinCommand) LongHelp() string { return "" }
func (cmd *hashinCommand) Hidden() bool { return true }

func (cmd *hashinCommand) Register(fs *flag.FlagSet) {
}

type hashinCommand struct{}

func (_ hashinCommand) Run(args []string) error {
p, err := nestContext.loadProject("")
if err != nil {
return err
}

sm, err := nestContext.sourceManager()
if err != nil {
return err
}
sm.UseDefaultSignalHandling()
defer sm.Release()

params := p.makeParams()
cpr, err := nestContext.splitAbsoluteProjectRoot(p.absroot)
if err != nil {
return errors.Wrap(err, "determineProjectRoot")
}

params.RootPackageTree, err = gps.ListPackages(p.absroot, cpr)
if err != nil {
return errors.Wrap(err, "gps.ListPackages")
}

s, err := gps.Prepare(params, sm)
if err != nil {
return errors.Wrap(err, "prepare solver")
}

fmt.Println(gps.HashingInputsAsString(s))
return nil
}
1 change: 1 addition & 0 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (cmd *initCommand) Name() string { return "init" }
func (cmd *initCommand) Args() string { return "[root]" }
func (cmd *initCommand) ShortHelp() string { return initShortHelp }
func (cmd *initCommand) LongHelp() string { return initLongHelp }
func (cmd *initCommand) Hidden() bool { return false }

func (cmd *initCommand) Register(fs *flag.FlagSet) {}

Expand Down
10 changes: 2 additions & 8 deletions init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package main
import (
"os"
"path/filepath"
"regexp"
"runtime"
"testing"
)
Expand Down Expand Up @@ -176,6 +175,7 @@ const Qux = "yo yo!"

sysCommit := tg.getCommit("go.googlesource.com/sys")
expectedLock := `{
"memo": "e5aa3024d5de3a019bf6541029effdcd434538399eb079f432635c8524d31238",
"projects": [
{
"name": "github.com/Sirupsen/logrus",
Expand Down Expand Up @@ -203,14 +203,8 @@ const Qux = "yo yo!"
]
}
`
lock := wipeMemo(tg.readLock())
lock := tg.readLock()
if lock != expectedLock {
t.Fatalf("expected %s, got %s", expectedLock, lock)
}
}

var memoRE = regexp.MustCompile(`\s+"memo": "[a-z0-9]+",`)

func wipeMemo(s string) string {
return memoRE.ReplaceAllString(s, "")
}
4 changes: 2 additions & 2 deletions lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"memo": "0c77f1de5f325906db6daf5260193d7de97af45498bc7155689395696cfd7c1b",
"memo": "cdafe8641b28cd16fe025df278b0a49b9416859345d8b6ba0ace0272b74925ee",
"projects": [
{
"name": "github.com/Masterminds/semver",
Expand Down Expand Up @@ -36,7 +36,7 @@
{
"name": "github.com/sdboyer/gps",
"branch": "master",
"revision": "669a62fc8b4b2c48757f6ff89aeba9eb8f287a9c",
"revision": "69fdac2db538237e27bbf7a68a305e78e0044591",
"packages": [
"."
]
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type command interface {
ShortHelp() string // "Foo the first bar"
LongHelp() string // "Foo the first bar meeting the following conditions..."
Register(*flag.FlagSet) // command-specific flags
Hidden() bool // indicates whether the command should be hidden from help output
Run([]string) error
}

Expand All @@ -52,6 +53,7 @@ func main() {
&statusCommand{},
&ensureCommand{},
&removeCommand{},
&hashinCommand{},
}

usage := func() {
Expand All @@ -61,7 +63,9 @@ func main() {
fmt.Fprintln(os.Stderr)
w := tabwriter.NewWriter(os.Stderr, 0, 4, 2, ' ', 0)
for _, command := range commands {
fmt.Fprintf(w, "\t%s\t%s\n", command.Name(), command.ShortHelp())
if !command.Hidden() {
fmt.Fprintf(w, "\t%s\t%s\n", command.Name(), command.ShortHelp())
}
}
w.Flush()
fmt.Fprintln(os.Stderr)
Expand Down
1 change: 1 addition & 0 deletions remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (cmd *removeCommand) Name() string { return "remove" }
func (cmd *removeCommand) Args() string { return "[spec...]" }
func (cmd *removeCommand) ShortHelp() string { return removeShortHelp }
func (cmd *removeCommand) LongHelp() string { return removeLongHelp }
func (cmd *removeCommand) Hidden() bool { return false }

func (cmd *removeCommand) Register(fs *flag.FlagSet) {
fs.BoolVar(&cmd.dryRun, "n", false, "dry run, don't actually remove anything")
Expand Down
3 changes: 2 additions & 1 deletion remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func main() {

sysCommit := tg.getCommit("go.googlesource.com/sys")
expectedLock := `{
"memo": "c2d1935d281595034e4afeb49d13981f4210badea72ac78c3eb2ba01f36c3ceb",
"projects": [
{
"name": "github.com/Sirupsen/logrus",
Expand Down Expand Up @@ -150,7 +151,7 @@ func main() {
]
}
`
lock := wipeMemo(tg.readLock())
lock := tg.readLock()
if lock != expectedLock {
t.Fatalf("expected %s, got %s", expectedLock, lock)
}
Expand Down
1 change: 1 addition & 0 deletions status.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (cmd *statusCommand) Name() string { return "status" }
func (cmd *statusCommand) Args() string { return "[package...]" }
func (cmd *statusCommand) ShortHelp() string { return statusShortHelp }
func (cmd *statusCommand) LongHelp() string { return statusLongHelp }
func (cmd *statusCommand) Hidden() bool { return false }

func (cmd *statusCommand) Register(fs *flag.FlagSet) {
fs.BoolVar(&cmd.detailed, "detailed", false, "report more detailed status")
Expand Down
16 changes: 10 additions & 6 deletions vendor/github.com/sdboyer/gps/analysis.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions vendor/github.com/sdboyer/gps/bridge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions vendor/github.com/sdboyer/gps/constraint_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions vendor/github.com/sdboyer/gps/constraints.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading