зеркало из https://github.com/golang/dep.git
Include memo in lock diff
This commit is contained in:
Родитель
e565a9f91e
Коммит
008ff041cc
|
@ -1,3 +1,4 @@
|
||||||
|
Memo: 595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c -> 2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e
|
||||||
Add: [
|
Add: [
|
||||||
{
|
{
|
||||||
"name": "github.com/stuff/realthing",
|
"name": "github.com/stuff/realthing",
|
||||||
|
|
|
@ -6,6 +6,7 @@ package dep
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -65,6 +66,10 @@ func (diff *LockDiff) Format() (string, error) {
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
if diff.HashDiff != nil {
|
||||||
|
buf.WriteString(fmt.Sprintf("Memo: %s\n", diff.HashDiff))
|
||||||
|
}
|
||||||
|
|
||||||
if len(diff.Add) > 0 {
|
if len(diff.Add) > 0 {
|
||||||
buf.WriteString("Add: ")
|
buf.WriteString("Add: ")
|
||||||
|
|
||||||
|
@ -121,23 +126,27 @@ type StringDiff struct {
|
||||||
Current string
|
Current string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (diff StringDiff) MarshalJSON() ([]byte, error) {
|
func (diff StringDiff) String() string {
|
||||||
var value string
|
|
||||||
|
|
||||||
if diff.Previous == "" && diff.Current != "" {
|
if diff.Previous == "" && diff.Current != "" {
|
||||||
value = fmt.Sprintf("+ %s", diff.Current)
|
return fmt.Sprintf("+ %s", diff.Current)
|
||||||
} else if diff.Previous != "" && diff.Current == "" {
|
|
||||||
value = fmt.Sprintf("- %s", diff.Previous)
|
|
||||||
} else if diff.Previous != diff.Current {
|
|
||||||
value = fmt.Sprintf("%s -> %s", diff.Previous, diff.Current)
|
|
||||||
} else {
|
|
||||||
value = diff.Current
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if diff.Previous != "" && diff.Current == "" {
|
||||||
|
return fmt.Sprintf("- %s", diff.Previous)
|
||||||
|
}
|
||||||
|
|
||||||
|
if diff.Previous != diff.Current {
|
||||||
|
return fmt.Sprintf("%s -> %s", diff.Previous, diff.Current)
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff.Current
|
||||||
|
}
|
||||||
|
|
||||||
|
func (diff StringDiff) MarshalJSON() ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
enc := json.NewEncoder(&buf)
|
enc := json.NewEncoder(&buf)
|
||||||
enc.SetEscapeHTML(false)
|
enc.SetEscapeHTML(false)
|
||||||
err := enc.Encode(value)
|
err := enc.Encode(diff.String())
|
||||||
|
|
||||||
return buf.Bytes(), err
|
return buf.Bytes(), err
|
||||||
}
|
}
|
||||||
|
@ -416,10 +425,10 @@ func diffLocks(l1 gps.Lock, l2 gps.Lock) *LockDiff {
|
||||||
|
|
||||||
diff := LockDiff{}
|
diff := LockDiff{}
|
||||||
|
|
||||||
h1 := l1.InputHash()
|
h1 := hex.EncodeToString(l1.InputHash())
|
||||||
h2 := l2.InputHash()
|
h2 := hex.EncodeToString(l2.InputHash())
|
||||||
if !bytes.Equal(h1, h2) {
|
if h1 != h2 {
|
||||||
diff.HashDiff = &StringDiff{Previous: string(h1), Current: string(h2)}
|
diff.HashDiff = &StringDiff{Previous: h1, Current: h2}
|
||||||
}
|
}
|
||||||
|
|
||||||
var i2next int
|
var i2next int
|
||||||
|
|
Загрузка…
Ссылка в новой задаче