Treat incomplete remote tag observations as uncertain
This commit is contained in:
@@ -43,7 +43,7 @@ const (
|
||||
)
|
||||
|
||||
// RemoteRef holds an exact ref's object and optional peeled commit. State is
|
||||
// RefConflict only when more than one exact result or malformed data is found.
|
||||
// RefConflict when records are inconsistent or incomplete.
|
||||
type RemoteRef struct {
|
||||
State RefState
|
||||
Object string
|
||||
@@ -130,7 +130,7 @@ func (endpoint Endpoint) Query(ctx context.Context, repositoryDir, tag string) (
|
||||
remoteTag = mergeRef(remoteTag, object, true)
|
||||
}
|
||||
}
|
||||
return Snapshot{Main: main, Tag: remoteTag}, nil
|
||||
return Snapshot{Main: main, Tag: finalizeRef(remoteTag)}, nil
|
||||
}
|
||||
|
||||
// RequireCandidate requires exact main equality and an absent remote
|
||||
@@ -294,6 +294,13 @@ func mergeRef(ref RemoteRef, object string, peeled bool) RemoteRef {
|
||||
return ref
|
||||
}
|
||||
|
||||
func finalizeRef(ref RemoteRef) RemoteRef {
|
||||
if ref.State == RefPresent && ref.Object == "" && ref.Peeled != "" {
|
||||
ref.State = RefConflict
|
||||
}
|
||||
return ref
|
||||
}
|
||||
|
||||
func checkTagRef(ctx context.Context, repositoryDir, tag string) error {
|
||||
if tag == "" {
|
||||
return fmt.Errorf("invalid Git tag name %q", tag)
|
||||
|
||||
Reference in New Issue
Block a user