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

Chase improvements to input hashing in gps #97

merged 7 commits into from
Jan 19, 2017

Conversation

sdboyer
Copy link
Member

@sdboyer sdboyer commented Jan 16, 2017

The only real change here is improvements to input hashing. That's both algorithm changes:

  • I tightened down the data included in the hash inputs considerably to avoid superfluous hash changes
  • Overrides are now much more, and hopefully completely, correct in how they show up
  • Constraints aren't incorporated if they're ineffectual - if the project neither imports nor requires anything under that constraint
  • I resolved a longstanding issue where the string outputs of constraints had no type information. This meant that a hash could match if, given everything else being the same, a constraint was on a branch foo and a constraint was on a tag/version foo. (This is visible in the output, where you'll see things like svc-^1.0.0 when the input constraint was ^1.0.0.)

And some output changes, via the HashingInputsAsString() func:

  1. Each discrete segment of input to the hasher gets a newline injected after it - far better for diffing and reading
  2. Headers demarcate the different sections of output, just so it's easier to scan and see which parts of the input data you're glancing at. (Happily, these being constant inputs, they have no variable effect on the hash output after being introduced)

Because this fixes (let's hope) issues with memoization, I also removed wipeMemo(), so this fixes #59.

@sdboyer
Copy link
Member Author

sdboyer commented Jan 16, 2017

Ugh...failure seems to probably be this:

job__40_1_-_golang_hoard_-_travis_ci

Which is probably caused by this change I merged: sdboyer/gps#141 . Guess that has unintended consequences, and I need to roll it back...

@sdboyer
Copy link
Member Author

sdboyer commented Jan 16, 2017

Adds a hash-inputs command that dumps the hash inputs. Also adds the capability to hide commands from help output, and makes hash-inputs hidden.

Obviously this is hacky, I'm happy to refactor if folks find it too objectionable.

@sdboyer
Copy link
Member Author

sdboyer commented Jan 16, 2017

hm, problem isn't sdboyer/gps#141. gotta be something else.

@sdboyer
Copy link
Member Author

sdboyer commented Jan 17, 2017

ah, i just needed to update the expected memo field. derp :)

@jessfraz
Copy link
Contributor

jessfraz commented Jan 17, 2017

If i run hoard ensure on this branch I get:

$ ./hoard ensure
ouchie, solve error: No versions of github.com/sdboyer/gps met constraints:
        master: Unable to update checked out version: fatal: reference is not a tree: 69fdac2db538237e27bbf7a68a305e78e0044591

        v0.13.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.13.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.12.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.11.2: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.11.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.11.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.10.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.10.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.9.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.8.2: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.8.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.8.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.7.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.6.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.5.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.5.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.4.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.3.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.2.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.1.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.0.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        master: Unable to update checked out version: fatal: reference is not a tree: 69fdac2db538237e27bbf7a68a305e78e0044591

        fix-race: Could not introduce github.com/sdboyer/gps@fix-race, as it is not allowed by constraint master from project github.com/golang/hoard.
refactor-hashing: Could not introduce github.com/sdboyer/gps@refactor-hashing, as it is not allowed by constraint master from project github.com/golang/hoard.
        sm-refactor: Could not introduce github.com/sdboyer/gps@sm-refactor, as it is not allowed by constraint master from project github.com/golang/hoard.ensure Solve(): No versions of github.com/sdboyer/gps met constraints:
        master: Unable to update checked out version: fatal: reference is not a tree: 69fdac2db538237e27bbf7a68a305e78e0044591

        v0.13.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.13.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.12.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.11.2: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.11.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.11.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.10.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.10.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.9.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.8.2: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.8.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.8.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.7.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.6.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.5.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.5.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.4.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.3.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.2.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.1.0: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.
        v0.0.1: Could not introduce github.com/sdboyer/[email protected], as it is not allowed by constraint master from project github.com/golang/hoard.

@sdboyer
Copy link
Member Author

sdboyer commented Jan 17, 2017

ugh. probably a stale repo on disk. i thought i had these cases covered, but dear god so much code.

could you cd $GOPATH/pkg/hoard/sources/https---github.com-sdboyer-gps and dump the results of git remote -av here?

once you do that, go ahead and blow away $GOPATH/pkg/hoard - that should fix it, right?

(not that that's an acceptable solution, just trying to work out why it's happening)

@jessfraz
Copy link
Contributor

jessfraz commented Jan 17, 2017

i think its because this PR updated vendor and not the lock & manifest tho right

@jessfraz
Copy link
Contributor

oh nevermind this does change the lock... ok weird

@jessfraz
Copy link
Contributor

jessfraz at jessfraz0 in ~/.go/pkg/hoard/sources/https---github.com-sdboyer-gps on 669a62f
$ git remote -v
origin  https://github.com/sdboyer/gps (fetch)
origin  [email protected]:sdboyer/gps (push)

@jessfraz
Copy link
Contributor

jessfraz commented Jan 17, 2017

ok after i blew it away I got no change to hash \0/

@jessfraz jessfraz mentioned this pull request Jan 17, 2017
@sdboyer
Copy link
Member Author

sdboyer commented Jan 18, 2017

OK i'll rebase and fix this sometime tonight.

i'm gonna need a serious regression test for this in gps, too. i thought i had this covered, but it's annoying enough to test for that i never actually set one up. now that i see i clearly don't have it covered, there's no more delaying it.

@@ -0,0 +1,53 @@
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

Signed-off-by: Jess Frazelle <[email protected]>
"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

@@ -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

func (cmd *hashinCommand) Args() string { return "" }
func (cmd *hashinCommand) ShortHelp() string { return "" }
func (cmd *hashinCommand) LongHelp() string { return "" }
func (cmd *hashinCommand) Hidden() bool { return false }
Copy link
Contributor

Choose a reason for hiding this comment

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

if we do need it, it should be hidden right?

Copy link
Member Author

Choose a reason for hiding this comment

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

LOL literally the reason why i added the Hidden func and, in my copy/paste fervor, i forgot to use it correctly here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests: stop wiping memo
3 participants