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
}
Example #3
0
File: main.go Project: 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())
		}
	}
}
Example #4
0
File: main.go Project: rhettg/ftl
func downloadPackageRevision(remote *ftl.RemoteRepository, local *ftl.LocalRepository, revision *ftl.RevisionInfo) error {
	fileName, r, err := remote.GetRevisionReader(revision)
	if err != nil {
		return fmt.Errorf("Failed listing: %v", err)
	}
	if r != nil {
		defer r.Close()
	}

	err = local.Add(revision, fileName, r)
	if err != nil {
		return fmt.Errorf("Failed adding %s: %v", revision.Name(), err)
	}
	return nil
}
Example #5
0
File: main.go Project: rhettg/ftl
func removePackageRevision(local *ftl.LocalRepository, revision *ftl.RevisionInfo) error {
	fmt.Println("Remove", revision.Name())
	return local.Remove(revision)
}
Example #6
0
File: main.go Project: rhettg/ftl
func listPackagesCmd(local *ftl.LocalRepository) {
	for _, revision := range local.ListPackages() {
		fmt.Println(revision)
	}
}