aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/error.go2
-rw-r--r--routers/api/v1/repo/key.go2
-rw-r--r--routers/repo/setting.go3
3 files changed, 6 insertions, 1 deletions
diff --git a/models/error.go b/models/error.go
index 1cab19aafd..364924c996 100644
--- a/models/error.go
+++ b/models/error.go
@@ -547,7 +547,7 @@ func IsErrDeployKeyNameAlreadyUsed(err error) bool {
}
func (err ErrDeployKeyNameAlreadyUsed) Error() string {
- return fmt.Sprintf("public key already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
+ return fmt.Sprintf("public key with name already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
}
// _____ ___________ __
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index 5d63a25d64..3d16ae6d40 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -177,6 +177,8 @@ func HandleAddKeyError(ctx *context.APIContext, err error) {
ctx.Error(http.StatusUnprocessableEntity, "", "Key content has been used as non-deploy key")
case models.IsErrKeyNameAlreadyUsed(err):
ctx.Error(http.StatusUnprocessableEntity, "", "Key title has been used")
+ case models.IsErrDeployKeyNameAlreadyUsed(err):
+ ctx.Error(http.StatusUnprocessableEntity, "", "A key with the same name already exists")
default:
ctx.Error(http.StatusInternalServerError, "AddKey", err)
}
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index ca222375fb..1b75522958 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -885,6 +885,9 @@ func DeployKeysPost(ctx *context.Context, form auth.AddKeyForm) {
case models.IsErrKeyNameAlreadyUsed(err):
ctx.Data["Err_Title"] = true
ctx.RenderWithErr(ctx.Tr("repo.settings.key_name_used"), tplDeployKeys, &form)
+ case models.IsErrDeployKeyNameAlreadyUsed(err):
+ ctx.Data["Err_Title"] = true
+ ctx.RenderWithErr(ctx.Tr("repo.settings.key_name_used"), tplDeployKeys, &form)
default:
ctx.ServerError("AddDeployKey", err)
}