mirror of
https://github.com/dolthub/dolt.git
synced 2025-12-31 00:50:14 -06:00
validate ref strings when resolving ref specs
This commit is contained in:
@@ -412,7 +412,7 @@ SQL
|
||||
[ $output -eq $CORRECT_DIFF ]
|
||||
}
|
||||
|
||||
@test "diff with branch@commit spec does not panic" {
|
||||
@test "diff with invalid ref does not panic" {
|
||||
dolt add .
|
||||
dolt commit -m table
|
||||
dolt checkout -b test-branch
|
||||
@@ -420,7 +420,13 @@ SQL
|
||||
dolt add test
|
||||
dolt commit -m "added row"
|
||||
FIRST_COMMIT=`dolt log | grep commit | cut -d " " -f 2 | tail -1`
|
||||
dolt diff $FIRST_COMMIT test-branch
|
||||
skip "The below panics."
|
||||
dolt diff master@$FIRST_COMMIT test-branch
|
||||
run dolt diff $FIRST_COMMIT test-branch
|
||||
[ $status -eq 0 ]
|
||||
[[ ! $output =~ "panic" ]]
|
||||
run dolt diff master@$FIRST_COMMIT test-branch
|
||||
[ $status -eq 1 ]
|
||||
[[ ! $output =~ "panic" ]]
|
||||
run dolt diff ref.with.period test-branch
|
||||
[ $status -eq 1 ]
|
||||
[[ ! $output =~ "panic" ]]
|
||||
}
|
||||
|
||||
@@ -187,6 +187,10 @@ func (ddb *DoltDB) WriteEmptyRepoWithCommitTime(ctx context.Context, name, email
|
||||
}
|
||||
|
||||
func getCommitStForRefStr(ctx context.Context, db datas.Database, ref string) (types.Struct, error) {
|
||||
if !datas.DatasetFullRe.MatchString(ref) {
|
||||
return types.EmptyStruct(db.Format()), fmt.Errorf("invalid ref format: %s", ref)
|
||||
}
|
||||
|
||||
ds, err := db.GetDataset(ctx, ref)
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user