Example #1
0
File: main.go Project: rhettg/ftl
func jumpCmd(lr *ftl.LocalRepository, revision *ftl.RevisionInfo) error {
	err := lr.Jump(revision)
	if err != nil {
		return fmt.Errorf("Failed to locally activate %s: %v", revision.Name(), err)
	}
	return nil
}
Example #2
0
File: main.go Project: rhettg/ftl
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
}