Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry-pick #7853 fix(gitextractor): update cli args when fetching remote repos #7863

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func NewCollectorStateManager(basicRes context.BasicRes, syncPolicy *models.Sync
return
}

// if timeAfter is not set or NOT before the previous vaule, we are in the incremental mode
// if timeAfter is not set or NOT before the previous value, we are in the incremental mode
if syncPolicy.TimeAfter == nil || state.TimeAfter == nil || !syncPolicy.TimeAfter.Before(*state.TimeAfter) {
stateManager.isIncremental = true
stateManager.since = state.LatestSuccessStart
Expand Down
2 changes: 1 addition & 1 deletion backend/helpers/pluginhelper/api/subtask_state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func NewSubtaskStateManager(args *SubtaskCommonArgs) (stateManager *SubtaskState
if syncPolicy.FullSync || state.PrevStartedAt == nil {
return
}
// if timeAfter is not set or NOT before the previous vaule, we are in the incremental mode
// if timeAfter is not set or NOT before the previous value, we are in the incremental mode
if (syncPolicy.TimeAfter == nil || state.TimeAfter == nil || !syncPolicy.TimeAfter.Before(*state.TimeAfter)) &&
// and the previous config is the same as the current config
(state.PrevConfig == "" || state.PrevConfig == stateManager.config) {
Expand Down
2 changes: 1 addition & 1 deletion backend/plugins/gitextractor/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (p GitExtractor) PrepareTaskData(taskCtx plugin.TaskContext, options map[st
return nil, errors.BadInput.Wrap(err, "failed to parse git url")
}

// append user name to the git url
// append username to the git url
if op.User != "" {
parsedURL.User = url.UserPassword(op.User, op.Password)
op.Url = parsedURL.String()
Expand Down
8 changes: 4 additions & 4 deletions backend/plugins/gitextractor/parser/clone_gitcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (g *GitcliCloner) CloneRepo(ctx plugin.SubTaskContext, localDir string) err
// deepen the commits by 1 more step to avoid https://github.com/apache/incubator-devlake/issues/7426
if since != nil {
// fixes error described on https://stackoverflow.com/questions/63878612/git-fatal-error-in-object-unshallow-sha-1
// It might be casued by the commit which being deepen has mulitple parent(e.g. a merge commit), not sure.
// It might be caused by the commit which being deepen has multiple parent(e.g. a merge commit), not sure.
if err := g.execGitCommandIn(ctx, localDir, "repack", "-d"); err != nil {
return errors.Default.Wrap(err, "failed to repack the repo")
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (g *GitcliCloner) execGitCloneCommand(ctx plugin.SubTaskContext, localDir s
if err := g.execGitCommand(ctx, cloneArgs...); err != nil {
return err
}
// 2. configure to fetch all branches from the remote server so we can collect new commits from them
// 2. configure to fetch all branches from the remote server, so we can collect new commits from them
gitConfig, err := os.OpenFile(path.Join(localDir, "config"), os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
return errors.Default.Wrap(err, "failed to open git config file")
Expand All @@ -137,7 +137,7 @@ func (g *GitcliCloner) execGitCloneCommand(ctx plugin.SubTaskContext, localDir s
if err != nil {
return errors.Default.Wrap(err, "failed to write to git config file")
}
// 3. fetch all branches with depth=1 so the next step would collect less commits
// 3. fetch all branches with depth=1 so the next step would collect fewer commits
// (I don't know why, but it reduced total number of commits from 18k to 7k on https://gitlab.com/gitlab-org/gitlab-foss.git with the same parameters)
fetchBranchesArgs := append([]string{"fetch", "--depth=1", "origin"}, args...)
if err := g.execGitCommandIn(ctx, localDir, fetchBranchesArgs...); err != nil {
Expand Down Expand Up @@ -169,7 +169,7 @@ func (g *GitcliCloner) execGitCommandIn(ctx plugin.SubTaskContext, workingDir st
env = append(env, fmt.Sprintf("HTTPS_PROXY=%s", taskData.Options.Proxy))
}
if taskData.ParsedURL.Scheme == "https" && ctx.GetConfigReader().GetBool("IN_SECURE_SKIP_VERIFY") {
args = append(args, "-c http.sslVerify=false")
args = append([]string{"-c http.sslVerify=false"}, args...)
}
} else if taskData.ParsedURL.Scheme == "ssh" {
var sshCmdArgs []string
Expand Down
Loading