Bug fix and tests for specifying --prune with a refspec

This commit is contained in:
Zach Musgrave
2023-08-02 12:07:06 -07:00
parent e0808a2ab6
commit 51e20d778d
4 changed files with 10 additions and 2 deletions

View File

@@ -110,7 +110,7 @@ func (cmd FetchCmd) Exec(ctx context.Context, commandStr string, args []string,
// validateFetchArgs returns an error if the arguments provided aren't valid.
func validateFetchArgs(apr *argparser.ArgParseResults, refSpecArgs []string) errhand.VerboseError {
if len(refSpecArgs) > 0 && apr.ContainsArg(cli.PruneFlag) {
if len(refSpecArgs) > 0 && apr.Contains(cli.PruneFlag) {
// The current prune implementation assumes that we're processing branch specs, which
return errhand.BuildDError("--prune option cannot be provided with a ref spec").Build()
}

View File

@@ -89,7 +89,7 @@ func doDoltFetch(ctx *sql.Context, args []string) (int, error) {
// validateFetchArgs returns an error if the arguments provided aren't valid.
func validateFetchArgs(apr *argparser.ArgParseResults, refSpecArgs []string) error {
if len(refSpecArgs) > 0 && apr.ContainsArg(cli.PruneFlag) {
if len(refSpecArgs) > 0 && apr.Contains(cli.PruneFlag) {
// The current prune implementation assumes that we're processing branch specs, which
return fmt.Errorf("--prune option cannot be provided with a ref spec")
}

View File

@@ -2420,4 +2420,8 @@ SQL
[ "$status" -eq 0 ]
[[ ! "$output" =~ "origin/b1" ]] || false
[[ ! "$output" =~ "remote2/b2" ]] || false
run dolt fetch --prune remote2 'refs/heads/main:refs/remotes/remote2/othermain'
[ "$status" -ne 0 ]
[[ "$output" =~ "--prune option cannot be provided with a ref spec" ]] || false
}

View File

@@ -431,6 +431,10 @@ teardown() {
[ "$status" -eq 0 ]
[[ ! "$output" =~ "origin/b1" ]] || false
[[ ! "$output" =~ "remote2/b2" ]] || false
run dolt sql -q "call dolt_fetch('--prune', 'remote2', 'refs/heads/main:refs/remotes/remote2/othermain')"
[ "$status" -ne 0 ]
[[ "$output" =~ "--prune option cannot be provided with a ref spec" ]] || false
}
@test "sql-fetch: dolt_fetch unknown remote fails" {