Skip to content

Commit 5677bcc

Browse files
committed
add error ErrMirrorLFSServerNotValid
1 parent 183c6d2 commit 5677bcc

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

models/error.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ func (err ErrNamePatternNotAllowed) Error() string {
5656
return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
5757
}
5858

59-
// ErrLFSNotInstalled represents an "git-lfs not found" error.
60-
type ErrLFSNotInstalled struct {
59+
// ErrMirrorLFSServerNotValid represents an "LFS Server not valid" error.
60+
type ErrMirrorLFSServerNotValid struct {
6161
}
6262

63-
// IsLFSNotInstalled checks if an error is an ErrLFSNotInstalled.
64-
func IsLFSNotInstalled(err error) bool {
65-
_, ok := err.(ErrLFSNotInstalled)
63+
// IsMirrorLFSServerValid checks if an error is an ErrMirrorLFSServerNotValid.
64+
func IsMirrorLFSServerValid(err error) bool {
65+
_, ok := err.(ErrMirrorLFSServerNotValid)
6666
return ok
6767
}
6868

69-
func (err ErrLFSNotInstalled) Error() string {
70-
return "git-lfs not found"
69+
func (err ErrMirrorLFSServerNotValid) Error() string {
70+
return "LFS Server not valid"
7171
}
7272

7373
// ErrNameCharsNotAllowed represents a "character not allowed in name" error.

models/repo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"net"
1919
"net/url"
2020
"os"
21-
"os/exec"
2221
"path"
2322
"path/filepath"
2423
"sort"
@@ -938,7 +937,7 @@ func (repo *Repository) CloneLink() (cl *CloneLink) {
938937
}
939938

940939
// CheckCreateRepository check if could created a repository
941-
func CheckCreateRepository(doer, u *User, name string, lfs bool, overwriteOrAdopt bool) error {
940+
func CheckCreateRepository(doer, u *User, name string, lfs bool, lfsServer string, overwriteOrAdopt bool) error {
942941
if !doer.CanCreateRepo() {
943942
return ErrReachLimitOfRepo{u.MaxRepoCreation}
944943
}
@@ -964,8 +963,9 @@ func CheckCreateRepository(doer, u *User, name string, lfs bool, overwriteOrAdop
964963
}
965964

966965
if lfs {
967-
if _, err := exec.LookPath("git-lfs"); err != nil {
968-
return ErrLFSNotInstalled{}
966+
u, err := url.ParseRequestURI(lfsServer)
967+
if err != nil {
968+
return ErrMirrorLFSServerNotValid{}
969969
}
970970
}
971971
return nil

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ user_not_exist = The user does not exist.
392392
team_not_exist = The team does not exist.
393393
last_org_owner = You cannot remove the last user from the 'owners' team. There must be at least one owner for an organization.
394394
cannot_add_org_to_team = An organization cannot be added as a team member.
395-
lfs_not_installed = Please <a rel="noreferrer" href="https://git-lfs.github.com">install</a> git-lfs.
395+
lfs_server_not_valid = LFS Server not valid.
396396
397397
invalid_ssh_key = Can not verify your SSH key: %s
398398
invalid_gpg_key = Can not verify your GPG key: %s

routers/repo/migrate.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ func handleMigrateError(ctx *context.Context, owner *models.User, err error, nam
102102
case models.IsErrNamePatternNotAllowed(err):
103103
ctx.Data["Err_RepoName"] = true
104104
ctx.RenderWithErr(ctx.Tr("repo.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), tpl, form)
105-
case models.IsLFSNotInstalled(err):
106-
ctx.Data["Err_LFSNotInstalled"] = true
107-
ctx.RenderWithErr(ctx.Tr("form.lfs_not_installed"), tpl, form)
105+
case models.IsMirrorLFSServerValid(err):
106+
ctx.Data["Err_LFSServerNotValid"] = true
107+
ctx.RenderWithErr(ctx.Tr("form.lfs_server_not_valid"), tpl, form)
108108
default:
109109
remoteAddr, _ := auth.ParseRemoteAddr(form.CloneAddr, form.AuthUsername, form.AuthPassword, owner)
110110
err = util.URLSanitizedError(err, remoteAddr)
@@ -200,7 +200,7 @@ func MigratePost(ctx *context.Context) {
200200
opts.Releases = false
201201
}
202202

203-
err = models.CheckCreateRepository(ctx.User, ctxUser, opts.RepoName, opts.LFS, false)
203+
err = models.CheckCreateRepository(ctx.User, ctxUser, opts.RepoName, opts.LFS, opts.LFSServer, false)
204204
if err != nil {
205205
handleMigrateError(ctx, ctxUser, err, "MigratePost", tpl, form)
206206
return

0 commit comments

Comments
 (0)