do not clone if already created
This commit is contained in:
@@ -19,8 +19,10 @@ package main
|
||||
*/
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
@@ -105,7 +107,9 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
|
||||
return fmt.Errorf("Error accessing/creating prjgit: %s err: %w", prjgit, err)
|
||||
}
|
||||
|
||||
common.PanicOnError(git.GitExec("", "clone", "--depth", "1", prjGitRepo.SSHURL, prjgit))
|
||||
if _, err := fs.Stat(os.DirFS(git.GetPath()), config.GitProjectName); errors.Is(err, os.ErrNotExist) {
|
||||
common.PanicOnError(git.GitExec("", "clone", "--depth", "1", prjGitRepo.SSHURL, prjgit))
|
||||
}
|
||||
|
||||
switch action.Action {
|
||||
case "created":
|
||||
@@ -186,7 +190,9 @@ func processConfiguredPushAction(action *common.PushWebhookEvent, config *common
|
||||
return fmt.Errorf("Error accessing/creating prjgit: %s err: %w", prjgit, err)
|
||||
}
|
||||
|
||||
common.PanicOnError(git.GitExec("", "clone", "--depth", "1", prjGitRepo.SSHURL, prjgit))
|
||||
if _, err := fs.Stat(os.DirFS(git.GetPath()), config.GitProjectName); errors.Is(err, os.ErrNotExist) {
|
||||
common.PanicOnError(git.GitExec("", "clone", "--depth", "1", prjGitRepo.SSHURL, prjgit))
|
||||
}
|
||||
if stat, err := os.Stat(filepath.Join(git.GetPath(), prjgit, action.Repository.Name)); err != nil || !stat.IsDir() {
|
||||
if DebugMode {
|
||||
log.Println("Pushed to package that is not part of the project. Ignoring:", err)
|
||||
@@ -229,7 +235,9 @@ func verifyProjectState(git common.Git, org string, config *common.AutogitConfig
|
||||
return fmt.Errorf("Error fetching or creating '%s/%s' -- aborting verifyProjectState(). Err: %w", org, config.GitProjectName, err)
|
||||
}
|
||||
|
||||
common.PanicOnError(git.GitExec("", "clone", "--depth", "1", repo.SSHURL, config.GitProjectName))
|
||||
if _, err := fs.Stat(os.DirFS(git.GetPath()), config.GitProjectName); errors.Is(err, os.ErrNotExist) {
|
||||
common.PanicOnError(git.GitExec("", "clone", "--depth", "1", repo.SSHURL, config.GitProjectName))
|
||||
}
|
||||
log.Println("getting submodule list")
|
||||
sub, err := git.GitSubmoduleList(config.GitProjectName, "HEAD")
|
||||
common.PanicOnError(err)
|
||||
|
Reference in New Issue
Block a user