forked from golang/dep
/
hash_in.go
51 lines (41 loc) · 1.26 KB
/
hash_in.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// 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
import (
"flag"
"github.com/golang/dep"
"github.com/golang/dep/gps"
"github.com/golang/dep/gps/pkgtree"
"github.com/pkg/errors"
)
func (cmd *hashinCommand) Name() string { return "hash-inputs" }
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(ctx *dep.Ctx, args []string) error {
p, err := ctx.LoadProject()
if err != nil {
return err
}
sm, err := ctx.SourceManager()
if err != nil {
return err
}
sm.UseDefaultSignalHandling()
defer sm.Release()
params := p.MakeParams()
params.RootPackageTree, err = pkgtree.ListPackages(p.ResolvedAbsRoot, string(p.ImportRoot))
if err != nil {
return errors.Wrap(err, "gps.ListPackages")
}
s, err := gps.Prepare(params, sm)
if err != nil {
return errors.Wrap(err, "prepare solver")
}
ctx.Out.Println(gps.HashingInputsAsString(s))
return nil
}