mirror of
https://github.com/cooperspencer/gickup
synced 2025-04-30 18:27:56 +02:00
fetch repos and added working parameter to config
This commit is contained in:
parent
64c0ce8285
commit
1ab13f350a
@ -107,6 +107,7 @@ destination:
|
||||
local:
|
||||
- path: /some/path/gickup
|
||||
structured: true # checks repos out like hostersite/user|organization/repo
|
||||
working: true # do not remove and clone the repo again if the pull fails
|
||||
|
||||
cron: 0 22 * * * # optional
|
||||
# https://crontab.guru/
|
||||
|
@ -114,10 +114,14 @@ func Locally(repo types.Repo, l types.Local, dry bool) {
|
||||
if err != nil {
|
||||
log.Fatal().Str("stage", "locally").Str("path", l.Path).Msg(err.Error())
|
||||
}
|
||||
w, err := r.Worktree()
|
||||
log.Info().Str("stage", "locally").Str("path", l.Path).Msgf("fetching %s", types.Green(repo.Name))
|
||||
err = r.Fetch(&git.FetchOptions{Auth: auth, RemoteName: "origin", Tags: git.AllTags, Force: true})
|
||||
if err != nil {
|
||||
log.Fatal().Str("stage", "locally").Str("path", l.Path).Msg(err.Error())
|
||||
if !strings.Contains(err.Error(), "already up-to-date") {
|
||||
log.Info().Str("stage", "locally").Str("path", l.Path).Msg(err.Error())
|
||||
}
|
||||
}
|
||||
w, err := r.Worktree()
|
||||
|
||||
log.Info().Str("stage", "locally").Str("path", l.Path).Msgf("pulling %s", types.Green(repo.Name))
|
||||
if !dry {
|
||||
@ -126,13 +130,17 @@ func Locally(repo types.Repo, l types.Local, dry bool) {
|
||||
if strings.Contains(err.Error(), "already up-to-date") {
|
||||
log.Info().Str("stage", "locally").Str("path", l.Path).Msg(err.Error())
|
||||
} else {
|
||||
if x == tries {
|
||||
log.Fatal().Str("stage", "locally").Str("path", l.Path).Msg(err.Error())
|
||||
if l.Working {
|
||||
log.Error().Str("stage", "locally").Str("path", l.Path).Err(err)
|
||||
} else {
|
||||
os.RemoveAll(repo.Name)
|
||||
log.Warn().Str("stage", "locally").Str("path", l.Path).Msgf("retry %s from %s", types.Red(x), types.Red(tries))
|
||||
time.Sleep(5 * time.Second)
|
||||
continue
|
||||
if x == tries {
|
||||
log.Fatal().Str("stage", "locally").Str("path", l.Path).Msg(err.Error())
|
||||
} else {
|
||||
os.RemoveAll(repo.Name)
|
||||
log.Warn().Str("stage", "locally").Str("path", l.Path).Msgf("retry %s from %s", types.Red(x), types.Red(tries))
|
||||
time.Sleep(5 * time.Second)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ type Destination struct {
|
||||
type Local struct {
|
||||
Path string `yaml:"path"`
|
||||
Structured bool `yaml:"structured"`
|
||||
Working bool `yaml:"working"`
|
||||
}
|
||||
|
||||
// Conf
|
||||
|
Loading…
Reference in New Issue
Block a user