Skip to content

Commit

Permalink
chore: 🔧 add debug logs while cloning repo and wikis
Browse files Browse the repository at this point in the history
  • Loading branch information
AkashRajpurohit committed Aug 22, 2024
1 parent 6a7bc77 commit 5a8dcbb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ func CloneOrUpdateRepo(repoOwner, repoName string, config config.Config) {
if _, err := os.Stat(repoPath); os.IsNotExist(err) {
logger.Info("Cloning repo: ", repoFullName)

cmd := exec.Command("git", "clone", "--bare", repoURL, repoPath)
if err := cmd.Run(); err != nil {
output, err := exec.Command("git", "clone", "--bare", repoURL, repoPath).CombinedOutput()
logger.Debugf("Output: %s\n", output)
if err != nil {
logger.Fatalf("Error cloning repo %s: %v\n", repoFullName, err)
} else {
logger.Info("Cloned repo: ", repoFullName)
}
} else {
logger.Info("Updating repo: ", repoFullName)

cmd := exec.Command("git", "--git-dir", repoPath, "fetch", "--prune", "origin", "+*:*")
if err := cmd.Run(); err != nil {
output, err := exec.Command("git", "--git-dir", repoPath, "fetch", "--prune", "origin", "+*:*").CombinedOutput()
logger.Debugf("Output: %s\n", output)
if err != nil {
logger.Fatalf("Error updating repo %s: %v\n", repoFullName, err)
} else {
logger.Info("Updated repo: ", repoFullName)
Expand All @@ -56,6 +58,7 @@ func SyncWiki(repoOwner, repoName string, config config.Config) {
logger.Info("Cloning wiki: ", repoFullName)

output, err := exec.Command("git", "clone", repoWikiURL, repoWikiPath).CombinedOutput()
logger.Debugf("Output: %s\n", output)
if err != nil {
exitErr, ok := err.(*exec.ExitError)
if ok && exitErr.ExitCode() == 128 {
Expand All @@ -75,8 +78,9 @@ func SyncWiki(repoOwner, repoName string, config config.Config) {
} else {
logger.Info("Updating wiki: ", repoFullName)

cmd := exec.Command("git", "-C", repoWikiPath, "pull", "--prune", "origin")
if err := cmd.Run(); err != nil {
output, err := exec.Command("git", "-C", repoWikiPath, "pull", "--prune", "origin").CombinedOutput()
logger.Debugf("Output: %s\n", output)
if err != nil {
logger.Fatalf("Error updating wiki %s: %v\n", repoFullName, err)
} else {
logger.Info("Updated wiki: ", repoFullName)
Expand Down

0 comments on commit 5a8dcbb

Please sign in to comment.