Skip to content

Commit

Permalink
Merge branch version/0-44-0-RC1 to adopt changes from PR #2997
Browse files Browse the repository at this point in the history
  • Loading branch information
as-builds committed Jan 9, 2024
2 parents 9756ab9 + bb5c00f commit 94fb6a6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/runbits/checkout/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/fileutils"
"github.com/ActiveState/cli/internal/language"
"github.com/ActiveState/cli/internal/osutils"
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/internal/runbits/git"
"github.com/ActiveState/cli/pkg/platform/authentication"
Expand Down Expand Up @@ -148,6 +149,9 @@ func (r *Checkout) Run(ns *project.Namespaced, branchName, cachePath, targetPath
LegacyCommitID: commitID.String(), // remove in DX-2307
})
if err != nil {
if osutils.IsAccessDeniedError(err) {
return "", &ErrNoPermission{err, path}
}
return "", errs.Wrap(err, "Could not create projectfile")
}
}
Expand Down
5 changes: 5 additions & 0 deletions internal/runbits/checkout/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type ErrAlreadyCheckedOut struct {
Path string
}

type ErrNoPermission struct {
error
Path string
}

func validatePath(ns *project.Namespaced, path string) error {
if !fileutils.TargetExists(path) {
return nil
Expand Down
6 changes: 6 additions & 0 deletions internal/runbits/checkout/rationalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
func (c *Checkout) rationalizeError(err *error) {
var errAlreadyCheckedOut *ErrAlreadyCheckedOut
var errProjectNotFound *model.ErrProjectNotFound
var errNoPermssion *ErrNoPermission

switch {
case err == nil:
Expand All @@ -26,5 +27,10 @@ func (c *Checkout) rationalizeError(err *error) {
errs.SetIf(!c.auth.Authenticated(), errs.SetTips(locale.T("tip_private_project_auth"))),
errs.SetInput(),
)
case errors.As(*err, &errNoPermssion):
*err = errs.WrapUserFacing(*err,
locale.Tl("err_checkout_os_permissions", "You do not have permission to check out to '{{.V0}}'. Please try elsewhere.", errNoPermssion.Path),
errs.SetInput(),
)
}
}

0 comments on commit 94fb6a6

Please sign in to comment.