Skip to content

Commit 140336c

Browse files
committed
Make migrations SKIP_TLS_VERIFY apply to git too
Make SKIP_TLS_VERIFY apply to git data migrations too Fix go-gitea#18998 Signed-off-by: Andrew Thornton <[email protected]>
1 parent fda5b9f commit 140336c

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

modules/git/repo.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,16 @@ func (repo *Repository) IsEmpty() (bool, error) {
9898

9999
// CloneRepoOptions options when clone a repository
100100
type CloneRepoOptions struct {
101-
Timeout time.Duration
102-
Mirror bool
103-
Bare bool
104-
Quiet bool
105-
Branch string
106-
Shared bool
107-
NoCheckout bool
108-
Depth int
109-
Filter string
101+
Timeout time.Duration
102+
Mirror bool
103+
Bare bool
104+
Quiet bool
105+
Branch string
106+
Shared bool
107+
NoCheckout bool
108+
Depth int
109+
Filter string
110+
SkipTLSVerify bool
110111
}
111112

112113
// Clone clones original repository to target path.
@@ -124,6 +125,9 @@ func CloneWithArgs(ctx context.Context, from, to string, args []string, opts Clo
124125
}
125126

126127
cmd := NewCommandContextNoGlobals(ctx, args...).AddArguments("clone")
128+
if opts.SkipTLSVerify {
129+
cmd.AddArguments("-c", "http.sslVerify=false")
130+
}
127131
if opts.Mirror {
128132
cmd.AddArguments("--mirror")
129133
}

modules/repository/repo.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
7272
}
7373

7474
if err = git.Clone(ctx, opts.CloneAddr, repoPath, git.CloneRepoOptions{
75-
Mirror: true,
76-
Quiet: true,
77-
Timeout: migrateTimeout,
75+
Mirror: true,
76+
Quiet: true,
77+
Timeout: migrateTimeout,
78+
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
7879
}); err != nil {
7980
return repo, fmt.Errorf("Clone: %v", err)
8081
}

0 commit comments

Comments
 (0)