with commit
This commit is contained in:
@@ -2,6 +2,11 @@ package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -66,7 +71,7 @@ func (pr *ProcessRepos) Process(ctx context.Context, repositoryUrls []string) er
|
||||
|
||||
pr.logger.Debug("Cloning repo", zap.String("path", area.Path), zap.String("repoUrl", repoUrl))
|
||||
cloneCtx, _ := context.WithTimeout(ctx, time.Second*5)
|
||||
_, err = pr.git.Clone(cloneCtx, area, repoUrl)
|
||||
repo, err := pr.git.Clone(cloneCtx, area, repoUrl)
|
||||
if err != nil {
|
||||
pr.logger.Error("could not clone repo", zap.Error(err))
|
||||
errChan <- err
|
||||
@@ -76,12 +81,39 @@ func (pr *ProcessRepos) Process(ctx context.Context, repositoryUrls []string) er
|
||||
err = pr.action.Run(
|
||||
ctx,
|
||||
area,
|
||||
func(ctx context.Context, area *storage.Area) (bool, error) {
|
||||
func(_ context.Context, area *storage.Area) (bool, error) {
|
||||
pr.logger.Debug("checking predicate", zap.String("area", area.Path))
|
||||
return true, nil
|
||||
contains := false
|
||||
filepath.WalkDir(area.Path, func(path string, d fs.DirEntry, err error) error {
|
||||
if d.Name() == "roadmap.md" {
|
||||
contains = true
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return contains, nil
|
||||
},
|
||||
func(ctx context.Context, area *storage.Area) error {
|
||||
func(_ context.Context, area *storage.Area) error {
|
||||
pr.logger.Debug("running action", zap.String("area", area.Path))
|
||||
readme := path.Join(area.Path, "README.md")
|
||||
file, err := os.Create(readme)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create readme: %w", err)
|
||||
}
|
||||
_, err = file.WriteString("# Readme")
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not write readme: %w", err)
|
||||
}
|
||||
|
||||
_, err = pr.git.Add(ctx, area, repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not add file: %w", err)
|
||||
}
|
||||
|
||||
_, err = pr.git.Commit(ctx, repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not get diff: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}, false)
|
||||
|
||||
|
Reference in New Issue
Block a user