-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(naming): Handle names with upper-case characters
Datasets that have names with upper-case characters should still work. But they should produce a warning when used, recommending a rename. The rename command doesn't warn about this. Handle everything to do with this check inside GetRefSelect. Clean up how GetRefSelect is called so that it seems less magical, and works closer to how it was intended. Add constants to make it more readable. Ignore bad case errors in lib.Resolve, since only cmd knows if such names are valid or not. Follow-up to #1308. Makes major progress on #1132.
- Loading branch information
Showing
19 changed files
with
186 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/qri-io/qri/dsref" | ||
"github.com/qri-io/qri/lib" | ||
) | ||
|
||
// EnsureFSIAgrees should be passed to GetCurrentRefSelect in order to ensure that any references | ||
// used by a command have agreement between what their .qri-ref linkfile thinks and what the | ||
// qri repository thinks. If there's a disagreement, the linkfile wins and the repository will | ||
// be updated to match. | ||
// This is useful if a user has a working directory, and then manually deletes the .qri-ref (which | ||
// will unlink the dataset), or renames / moves the directory and then runs a command in that | ||
// directory (which will update the repository with the new working directory's path). | ||
func EnsureFSIAgrees(f *lib.FSIMethods) *FSIRefLinkEnsurer { | ||
if f == nil { | ||
return nil | ||
} | ||
return &FSIRefLinkEnsurer{FSIMethods: f} | ||
} | ||
|
||
// FSIRefLinkEnsurer is a simple wrapper for ensuring the linkfile agrees with the repository. We | ||
// use it instead of a raw FSIMethods pointer so that users of this code see they need to call | ||
// EnsureFSIAgrees(*fsiMethods) when calling GetRefSelect, hopefully providing a bit of insight | ||
// about what this parameter is for. | ||
type FSIRefLinkEnsurer struct { | ||
FSIMethods *lib.FSIMethods | ||
} | ||
|
||
// EnsureRef checks if the linkfile and repository agree on the dataset's working directory path. | ||
// If not, it will modify the repository so that it matches the linkfile. The linkfile will | ||
// never be modified. | ||
func (e *FSIRefLinkEnsurer) EnsureRef(refs *RefSelect) error { | ||
if e == nil { | ||
return nil | ||
} | ||
p := lib.EnsureParams{Dir: refs.Dir(), Ref: refs.Ref()} | ||
info := dsref.VersionInfo{} | ||
// Lib call matches the gorpc method signature, but `out` is not used | ||
err := e.FSIMethods.EnsureRef(&p, &info) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.