Esempio n. 1
0
File: main.go Progetto: rhettg/ftl
func retrieveRemoteRevisions(r *ftl.RemoteRepository, packageName string) (curRev, prevRev *ftl.RevisionInfo, revisions []*ftl.RevisionInfo, err error) {
	crChan := make(chan ftl.RevisionListResult)
	go func() {
		currentRev, err := r.GetCurrentRevision(packageName)
		crChan <- ftl.RevisionListResult{[]*ftl.RevisionInfo{currentRev}, err}
	}()

	prChan := make(chan ftl.RevisionListResult)
	go func() {
		previousRev, err := r.GetPreviousRevision(packageName)
		prChan <- ftl.RevisionListResult{[]*ftl.RevisionInfo{previousRev}, err}
	}()

	rrChan := make(chan ftl.RevisionListResult)
	go func() {
		remoteRevisions, err := r.ListRevisions(packageName)
		rrChan <- ftl.RevisionListResult{remoteRevisions, err}
	}()

	crResult := <-crChan
	if crResult.Err != nil {
		err = fmt.Errorf("Failed to retrieve current revision")
	} else {
		curRev = crResult.Revisions[0]
	}

	prResult := <-prChan
	if prResult.Err != nil {
		err = fmt.Errorf("Failed to retrieve previous revision")
	} else {
		prevRev = prResult.Revisions[0]
	}

	rrResult := <-rrChan
	if rrResult.Err != nil {
		err = fmt.Errorf("Failed to retrieve remote revisions")
	} else {
		revisions = rrResult.Revisions
	}

	return
}
Esempio n. 2
0
File: main.go Progetto: rhettg/ftl
func listRemoteCmd(rr *ftl.RemoteRepository, packageName string) error {
	activeRev, err := rr.GetCurrentRevision(packageName)
	if err != nil {
		return err
	}

	revisionList, err := rr.ListRevisions(packageName)
	if err != nil {
		return err
	}

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

	return nil
}