Esempio n. 1
0
File: main.go Progetto: 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
}
Esempio n. 2
0
File: main.go Progetto: rhettg/ftl
func listCmd(lr *ftl.LocalRepository, packageName string) {
	activeRev := lr.GetCurrentRevision(packageName)

	for _, revision := range lr.ListRevisions(packageName) {
		if activeRev != nil && *revision == *activeRev {
			fmt.Printf("%s\t(active)\n", revision.Name())
		} else {
			fmt.Println(revision.Name())
		}
	}
}