Merge pull request #523 from josharian/diff-stringers
make Delta and DiffLineType stringers
This commit is contained in:
commit
11506ab070
|
@ -0,0 +1,33 @@
|
|||
// Code generated by "stringer -type Delta -trimprefix Delta -tags static"; DO NOT EDIT.
|
||||
|
||||
package git
|
||||
|
||||
import "strconv"
|
||||
|
||||
func _() {
|
||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||
// Re-run the stringer command to generate them again.
|
||||
var x [1]struct{}
|
||||
_ = x[DeltaUnmodified-0]
|
||||
_ = x[DeltaAdded-1]
|
||||
_ = x[DeltaDeleted-2]
|
||||
_ = x[DeltaModified-3]
|
||||
_ = x[DeltaRenamed-4]
|
||||
_ = x[DeltaCopied-5]
|
||||
_ = x[DeltaIgnored-6]
|
||||
_ = x[DeltaUntracked-7]
|
||||
_ = x[DeltaTypeChange-8]
|
||||
_ = x[DeltaUnreadable-9]
|
||||
_ = x[DeltaConflicted-10]
|
||||
}
|
||||
|
||||
const _Delta_name = "UnmodifiedAddedDeletedModifiedRenamedCopiedIgnoredUntrackedTypeChangeUnreadableConflicted"
|
||||
|
||||
var _Delta_index = [...]uint8{0, 10, 15, 22, 30, 37, 43, 50, 59, 69, 79, 89}
|
||||
|
||||
func (i Delta) String() string {
|
||||
if i < 0 || i >= Delta(len(_Delta_index)-1) {
|
||||
return "Delta(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _Delta_name[_Delta_index[i]:_Delta_index[i+1]]
|
||||
}
|
4
diff.go
4
diff.go
|
@ -39,6 +39,8 @@ const (
|
|||
DeltaConflicted Delta = C.GIT_DELTA_CONFLICTED
|
||||
)
|
||||
|
||||
//go:generate stringer -type Delta -trimprefix Delta -tags static
|
||||
|
||||
type DiffLineType int
|
||||
|
||||
const (
|
||||
|
@ -54,6 +56,8 @@ const (
|
|||
DiffLineBinary DiffLineType = C.GIT_DIFF_LINE_BINARY
|
||||
)
|
||||
|
||||
//go:generate stringer -type DiffLineType -trimprefix DiffLine -tags static
|
||||
|
||||
type DiffFile struct {
|
||||
Path string
|
||||
Oid *Oid
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
// Code generated by "stringer -type DiffLineType -trimprefix DiffLine -tags static"; DO NOT EDIT.
|
||||
|
||||
package git
|
||||
|
||||
import "strconv"
|
||||
|
||||
func _() {
|
||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||
// Re-run the stringer command to generate them again.
|
||||
var x [1]struct{}
|
||||
_ = x[DiffLineContext-32]
|
||||
_ = x[DiffLineAddition-43]
|
||||
_ = x[DiffLineDeletion-45]
|
||||
_ = x[DiffLineContextEOFNL-61]
|
||||
_ = x[DiffLineAddEOFNL-62]
|
||||
_ = x[DiffLineDelEOFNL-60]
|
||||
_ = x[DiffLineFileHdr-70]
|
||||
_ = x[DiffLineHunkHdr-72]
|
||||
_ = x[DiffLineBinary-66]
|
||||
}
|
||||
|
||||
const (
|
||||
_DiffLineType_name_0 = "Context"
|
||||
_DiffLineType_name_1 = "Addition"
|
||||
_DiffLineType_name_2 = "Deletion"
|
||||
_DiffLineType_name_3 = "DelEOFNLContextEOFNLAddEOFNL"
|
||||
_DiffLineType_name_4 = "Binary"
|
||||
_DiffLineType_name_5 = "FileHdr"
|
||||
_DiffLineType_name_6 = "HunkHdr"
|
||||
)
|
||||
|
||||
var (
|
||||
_DiffLineType_index_3 = [...]uint8{0, 8, 20, 28}
|
||||
)
|
||||
|
||||
func (i DiffLineType) String() string {
|
||||
switch {
|
||||
case i == 32:
|
||||
return _DiffLineType_name_0
|
||||
case i == 43:
|
||||
return _DiffLineType_name_1
|
||||
case i == 45:
|
||||
return _DiffLineType_name_2
|
||||
case 60 <= i && i <= 62:
|
||||
i -= 60
|
||||
return _DiffLineType_name_3[_DiffLineType_index_3[i]:_DiffLineType_index_3[i+1]]
|
||||
case i == 66:
|
||||
return _DiffLineType_name_4
|
||||
case i == 70:
|
||||
return _DiffLineType_name_5
|
||||
case i == 72:
|
||||
return _DiffLineType_name_6
|
||||
default:
|
||||
return "DiffLineType(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue