mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 13:24:18 +01:00
Make migrations SKIP_TLS_VERIFY apply to git too (#19132)
Make SKIP_TLS_VERIFY apply to git data migrations too through adding the `-c http.sslVerify=false` option to the git clone command. Fix #18998 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
fb08d2b3fd
commit
2d21d2af9e
3 changed files with 32 additions and 23 deletions
|
@ -98,15 +98,16 @@ func (repo *Repository) IsEmpty() (bool, error) {
|
||||||
|
|
||||||
// CloneRepoOptions options when clone a repository
|
// CloneRepoOptions options when clone a repository
|
||||||
type CloneRepoOptions struct {
|
type CloneRepoOptions struct {
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
Mirror bool
|
Mirror bool
|
||||||
Bare bool
|
Bare bool
|
||||||
Quiet bool
|
Quiet bool
|
||||||
Branch string
|
Branch string
|
||||||
Shared bool
|
Shared bool
|
||||||
NoCheckout bool
|
NoCheckout bool
|
||||||
Depth int
|
Depth int
|
||||||
Filter string
|
Filter string
|
||||||
|
SkipTLSVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone clones original repository to target path.
|
// Clone clones original repository to target path.
|
||||||
|
@ -124,6 +125,9 @@ func CloneWithArgs(ctx context.Context, from, to string, args []string, opts Clo
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := NewCommandContextNoGlobals(ctx, args...).AddArguments("clone")
|
cmd := NewCommandContextNoGlobals(ctx, args...).AddArguments("clone")
|
||||||
|
if opts.SkipTLSVerify {
|
||||||
|
cmd.AddArguments("-c", "http.sslVerify=false")
|
||||||
|
}
|
||||||
if opts.Mirror {
|
if opts.Mirror {
|
||||||
cmd.AddArguments("--mirror")
|
cmd.AddArguments("--mirror")
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,10 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = git.Clone(ctx, opts.CloneAddr, repoPath, git.CloneRepoOptions{
|
if err = git.Clone(ctx, opts.CloneAddr, repoPath, git.CloneRepoOptions{
|
||||||
Mirror: true,
|
Mirror: true,
|
||||||
Quiet: true,
|
Quiet: true,
|
||||||
Timeout: migrateTimeout,
|
Timeout: migrateTimeout,
|
||||||
|
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return repo, fmt.Errorf("Clone: %v", err)
|
return repo, fmt.Errorf("Clone: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -88,10 +89,11 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = git.Clone(ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
|
if err = git.Clone(ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
|
||||||
Mirror: true,
|
Mirror: true,
|
||||||
Quiet: true,
|
Quiet: true,
|
||||||
Timeout: migrateTimeout,
|
Timeout: migrateTimeout,
|
||||||
Branch: "master",
|
Branch: "master",
|
||||||
|
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Warn("Clone wiki: %v", err)
|
log.Warn("Clone wiki: %v", err)
|
||||||
if err := util.RemoveAll(wikiPath); err != nil {
|
if err := util.RemoveAll(wikiPath); err != nil {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
base "code.gitea.io/gitea/modules/migration"
|
base "code.gitea.io/gitea/modules/migration"
|
||||||
"code.gitea.io/gitea/modules/repository"
|
"code.gitea.io/gitea/modules/repository"
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/structs"
|
"code.gitea.io/gitea/modules/structs"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
@ -149,9 +150,10 @@ func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOp
|
||||||
}
|
}
|
||||||
|
|
||||||
err = git.Clone(g.ctx, remoteAddr, repoPath, git.CloneRepoOptions{
|
err = git.Clone(g.ctx, remoteAddr, repoPath, git.CloneRepoOptions{
|
||||||
Mirror: true,
|
Mirror: true,
|
||||||
Quiet: true,
|
Quiet: true,
|
||||||
Timeout: migrateTimeout,
|
Timeout: migrateTimeout,
|
||||||
|
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Clone: %v", err)
|
return fmt.Errorf("Clone: %v", err)
|
||||||
|
@ -166,10 +168,11 @@ func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOp
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := git.Clone(g.ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
|
if err := git.Clone(g.ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
|
||||||
Mirror: true,
|
Mirror: true,
|
||||||
Quiet: true,
|
Quiet: true,
|
||||||
Timeout: migrateTimeout,
|
Timeout: migrateTimeout,
|
||||||
Branch: "master",
|
Branch: "master",
|
||||||
|
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Warn("Clone wiki: %v", err)
|
log.Warn("Clone wiki: %v", err)
|
||||||
if err := os.RemoveAll(wikiPath); err != nil {
|
if err := os.RemoveAll(wikiPath); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue