func syncCmd(remote *ftl.RemoteRepository, local *ftl.LocalRepository) error { for _, packageName := range local.ListPackages() { err := local.CheckPackage(packageName) if err != nil { fmt.Println("Package initialize failed", err) return err } curRev, prevRev, remoteRevisions, err := retrieveRemoteRevisions(remote, packageName) if err != nil { return err } var firstRev *ftl.RevisionInfo = nil if prevRev != nil { firstRev = prevRev // Special case for post-jump-back, where prev might be more // current than cur if curRev != nil && curRev.Revision < firstRev.Revision { firstRev = curRev } } localRevisions := local.ListRevisions(packageName) download, purge, err := syncPackage(remoteRevisions, localRevisions, firstRev) if err != nil { return err } err = downloadRemoteRevisions(remote, local, download) if curRev != nil { err = local.Jump(curRev) if err != nil { return err } } if prevRev != nil { err = local.SetPreviousJump(prevRev) if err != nil { return err } } for _, rev := range purge { err = removePackageRevision(local, rev) if err != nil { return err } } } return nil }
func listPackagesCmd(local *ftl.LocalRepository) { for _, revision := range local.ListPackages() { fmt.Println(revision) } }