Skip to content

Commit 56a1cb4

Browse files
authored
Merge pull request ActiveState#3490 from ActiveState/mitchell/dx-3050
Do not validate commit ID from within projectfile.
2 parents f9ffd04 + 07fa246 commit 56a1cb4

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

pkg/projectfile/projectfile.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/ActiveState/cli/internal/sliceutils"
3232
"github.com/ActiveState/cli/internal/strutils"
3333
"github.com/ActiveState/cli/pkg/sysinfo"
34-
"github.com/go-openapi/strfmt"
3534
"github.com/google/uuid"
3635
"github.com/imdario/mergo"
3736
"github.com/spf13/cast"
@@ -660,19 +659,6 @@ func (p *Project) parseURL() (projectURL, error) {
660659
return parseURL(p.Project)
661660
}
662661

663-
func validateUUID(uuidStr string) error {
664-
if ok := strfmt.Default.Validates("uuid", uuidStr); !ok {
665-
return locale.NewError("err_commit_id_invalid", "", uuidStr)
666-
}
667-
668-
var uuid strfmt.UUID
669-
if err := uuid.UnmarshalText([]byte(uuidStr)); err != nil {
670-
return locale.WrapError(err, "err_commit_id_unmarshal", "Failed to unmarshal the commit id {{.V0}} read from activestate.yaml.", uuidStr)
671-
}
672-
673-
return nil
674-
}
675-
676662
func parseURL(rawURL string) (projectURL, error) {
677663
p := projectURL{}
678664

@@ -701,12 +687,6 @@ func parseURL(rawURL string) (projectURL, error) {
701687
p.LegacyCommitID = c
702688
}
703689

704-
if p.LegacyCommitID != "" {
705-
if err := validateUUID(p.LegacyCommitID); err != nil {
706-
return p, err
707-
}
708-
}
709-
710690
if b := q.Get("branch"); b != "" {
711691
p.BranchName = b
712692
}

pkg/projectfile/projectfile_test.go

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -377,48 +377,39 @@ func TestValidateProjectURL(t *testing.T) {
377377

378378
func Test_parseURL(t *testing.T) {
379379
tests := []struct {
380-
name string
381-
rawURL string
382-
want projectURL
383-
wantErr bool
380+
name string
381+
rawURL string
382+
want projectURL
384383
}{
385384
{
386-
"Valid full legacy URL",
385+
"Full URL",
387386
"https://platform.activestate.com/Owner/Name?commitID=7BA74758-8665-4D3F-921C-757CD271A0C1&branch=main",
388387
projectURL{
389388
Owner: "Owner",
390389
Name: "Name",
391390
LegacyCommitID: "7BA74758-8665-4D3F-921C-757CD271A0C1",
392391
BranchName: "main",
393392
},
394-
false,
395393
},
396394
{
397-
"Valid commit URL",
395+
"Legacy commit URL",
398396
"https://platform.activestate.com/commit/7BA74758-8665-4D3F-921C-757CD271A0C1",
399397
projectURL{
400398
Owner: "",
401399
Name: "",
402400
LegacyCommitID: "7BA74758-8665-4D3F-921C-757CD271A0C1",
403401
BranchName: "",
404402
},
405-
false,
406-
},
407-
{
408-
"Invalid commit",
409-
"https://platform.activestate.com/commit/nope",
410-
projectURL{},
411-
true,
412403
},
413404
}
414405
for _, tt := range tests {
415406
t.Run(tt.name, func(t *testing.T) {
416407
got, err := parseURL(tt.rawURL)
417-
if (err != nil) != tt.wantErr {
418-
t.Errorf("parseURL() error = %v, wantErr %v", err, tt.wantErr)
408+
if err != nil {
409+
t.Errorf("parseURL() error = %v", err)
419410
return
420411
}
421-
if !tt.wantErr && !reflect.DeepEqual(got, tt.want) {
412+
if !reflect.DeepEqual(got, tt.want) {
422413
t.Errorf("parseURL() got = %v, want %v", got, tt.want)
423414
}
424415
})

0 commit comments

Comments
 (0)