Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit 2c286aa

Browse files
author
Daishan Peng
committed
sort trash.lock
1 parent 11d7176 commit 2c286aa

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

conf/conf.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ type Import struct {
2929
Options `yaml:",inline"`
3030
}
3131

32+
type Imports []Import
33+
34+
func (i Imports) Len() int {
35+
return len(i)
36+
}
37+
38+
func (i Imports) Less(k, j int) bool {
39+
return strings.Compare(i[k].Package, i[j].Package) <= 0
40+
}
41+
42+
func (i Imports) Swap(k, j int) {
43+
tmp := i[j]
44+
i[j] = i[k]
45+
i[k] = tmp
46+
return
47+
}
48+
3249
type Options struct {
3350
Transitive bool `yaml:"transitive,omitempty"`
3451
Staging bool `yaml:"staging,omitempty"`

trash.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os/exec"
1313
"path"
1414
"path/filepath"
15+
"sort"
1516
"strings"
1617

1718
"github.com/Sirupsen/logrus"
@@ -1033,6 +1034,7 @@ func cleanup(update bool, dir, targetDir string, trashConf *conf.Conf) error {
10331034
writeConf.Imports = append(writeConf.Imports, i)
10341035
}
10351036
}
1037+
sort.Sort(conf.Imports(writeConf.Imports))
10361038
data, err := yaml.Marshal(writeConf)
10371039
if err != nil {
10381040
return err

trash.lock

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package: github.com/rancher/trash
2+
import:
3+
- package: github.com/Masterminds/glide
4+
version: fb6c62596ce1b29128f1ef7e329c367a648ee9b1
5+
repo: https://github.com/StrongMonkey/glide.git
6+
- package: github.com/Masterminds/vcs
7+
version: v1.12.0
8+
- package: github.com/Sirupsen/logrus
9+
version: v0.10.0
10+
- package: github.com/cloudfoundry-incubator/candiedyaml
11+
version: 99c3df8
12+
- package: github.com/davecgh/go-spew
13+
version: 5215b55
14+
- package: github.com/mitchellh/go-homedir
15+
version: b8bc1bf767474819792c23f32d8286a45736f1c6
16+
- package: github.com/pmezard/go-difflib
17+
version: 792786c
18+
- package: github.com/stretchr/testify
19+
version: v1.1.3
20+
- package: github.com/urfave/cli
21+
version: v1.18.0
22+
- package: golang.org/x/sys
23+
version: a408501
24+
- package: gopkg.in/yaml.v2
25+
version: eb3733d160e74a9c7e442f435eb3bea458e1d19f

0 commit comments

Comments
 (0)