aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-03-19 14:16:38 +0000
committerGitHub <noreply@github.com>2022-03-19 14:16:38 +0000
commit2d21d2af9ef907ed3407b07d6a0191c39a29ee54 (patch)
tree8beaec74bab15d8e74219120d966f9eec0bf2bf5 /modules
parentfb08d2b3fd04dc8fc6cbd45fd341773b817c0857 (diff)
downloadgitea-2d21d2af9ef907ed3407b07d6a0191c39a29ee54.tar.gz
gitea-2d21d2af9ef907ed3407b07d6a0191c39a29ee54.zip
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>
Diffstat (limited to 'modules')
-rw-r--r--modules/git/repo.go22
-rw-r--r--modules/repository/repo.go16
2 files changed, 22 insertions, 16 deletions
diff --git a/modules/git/repo.go b/modules/git/repo.go
index 8217521b06..5ba39ac7e3 100644
--- a/modules/git/repo.go
+++ b/modules/git/repo.go
@@ -98,15 +98,16 @@ func (repo *Repository) IsEmpty() (bool, error) {
// CloneRepoOptions options when clone a repository
type CloneRepoOptions struct {
- Timeout time.Duration
- Mirror bool
- Bare bool
- Quiet bool
- Branch string
- Shared bool
- NoCheckout bool
- Depth int
- Filter string
+ Timeout time.Duration
+ Mirror bool
+ Bare bool
+ Quiet bool
+ Branch string
+ Shared bool
+ NoCheckout bool
+ Depth int
+ Filter string
+ SkipTLSVerify bool
}
// 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")
+ if opts.SkipTLSVerify {
+ cmd.AddArguments("-c", "http.sslVerify=false")
+ }
if opts.Mirror {
cmd.AddArguments("--mirror")
}
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index ed9ed508be..13710bd4ab 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -72,9 +72,10 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
}
if err = git.Clone(ctx, opts.CloneAddr, repoPath, git.CloneRepoOptions{
- Mirror: true,
- Quiet: true,
- Timeout: migrateTimeout,
+ Mirror: true,
+ Quiet: true,
+ Timeout: migrateTimeout,
+ SkipTLSVerify: setting.Migrations.SkipTLSVerify,
}); err != nil {
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{
- Mirror: true,
- Quiet: true,
- Timeout: migrateTimeout,
- Branch: "master",
+ Mirror: true,
+ Quiet: true,
+ Timeout: migrateTimeout,
+ Branch: "master",
+ SkipTLSVerify: setting.Migrations.SkipTLSVerify,
}); err != nil {
log.Warn("Clone wiki: %v", err)
if err := util.RemoveAll(wikiPath); err != nil {