diff options
-rw-r--r-- | src/qtmoduleupdater/main.go | 42 | ||||
-rw-r--r-- | src/qtmoduleupdater/moduleupdatebatch.go | 46 |
2 files changed, 50 insertions, 38 deletions
diff --git a/src/qtmoduleupdater/main.go b/src/qtmoduleupdater/main.go index 6dc325d2..0ad79735 100644 --- a/src/qtmoduleupdater/main.go +++ b/src/qtmoduleupdater/main.go @@ -92,19 +92,9 @@ func appMain() error { } } - batch := &ModuleUpdateBatch{ - Product: product, - ProductRef: productRef, - Branch: branch, - } - var err error - - err = batch.loadState() - if os.IsNotExist(err) { - err = batch.loadTodoList() - if err != nil { - return err - } + batch, err := newModuleUpdateBatch(product, branch, productRef) + if err != nil { + return err } if summaryOnly { @@ -112,31 +102,7 @@ func appMain() error { return nil } - batch.checkPendingModules() - - if err := batch.scheduleUpdates(gerrit); err != nil { - return err - } - - batch.printSummary() - - if !batch.isDone() { - err = batch.saveState() - if err != nil { - return err - } - } else { - if batch.FailedModuleCount == 0 { - fmt.Println("Preparing qt5 update") - if err = prepareQt5Update(product, batch.Branch, batch.Done, gerrit); err != nil { - return fmt.Errorf("error preparing qt5 update: %s", err) - } - } - - batch.clearState() - } - - return nil + return batch.runOneIteration(gerrit) } func main() { diff --git a/src/qtmoduleupdater/moduleupdatebatch.go b/src/qtmoduleupdater/moduleupdatebatch.go index dfdde6fe..d8a7205a 100644 --- a/src/qtmoduleupdater/moduleupdatebatch.go +++ b/src/qtmoduleupdater/moduleupdatebatch.go @@ -53,6 +53,24 @@ type ModuleUpdateBatch struct { FailedModuleCount int } +func newModuleUpdateBatch(product string, branch string, productRef string) (*ModuleUpdateBatch, error) { + batch := &ModuleUpdateBatch{ + Product: product, + ProductRef: productRef, + Branch: branch, + } + var err error + + err = batch.loadState() + if os.IsNotExist(err) { + err = batch.loadTodoList() + if err != nil { + return nil, err + } + } + return batch, nil +} + func (batch *ModuleUpdateBatch) scheduleUpdates(gerrit *gerritInstance) error { for _, moduleToUpdate := range batch.Todo { update, err := moduleToUpdate.updateDependenciesForModule(batch.Done) @@ -241,3 +259,31 @@ func (batch *ModuleUpdateBatch) printSummary() { fmt.Println() fmt.Println() } + +func (batch *ModuleUpdateBatch) runOneIteration(gerrit *gerritInstance) error { + batch.checkPendingModules() + + if err := batch.scheduleUpdates(gerrit); err != nil { + return err + } + + batch.printSummary() + + if !batch.isDone() { + err := batch.saveState() + if err != nil { + return err + } + } else { + if batch.FailedModuleCount == 0 { + fmt.Println("Preparing qt5 update") + if err := prepareQt5Update(batch.Product, batch.Branch, batch.Done, gerrit); err != nil { + return fmt.Errorf("error preparing qt5 update: %s", err) + } + } + + batch.clearState() + } + + return nil +} |