示例#1
0
// Clone implements vcsstore.Service and clones a repository.
func (c *Client) Clone(vcsType string, cloneURL *url.URL, opt vcs.RemoteOpts) (interface{}, error) {
	key := vcsstore.EncodeRepositoryPath(vcsType, cloneURL)

	_, err := c.datad.Update(key)
	if err != nil {
		return nil, err
	}

	// TODO(sqs): add option for waiting for clone (triggered by Update) to
	// complete?

	return c.Open(vcsType, cloneURL)
}
示例#2
0
// Open implements vcsstore.Service and opens a repository. If the repository
// does not exist in the cluster, an os.ErrNotExist-satisfying error is
// returned.
func (c *Client) Open(vcsType string, cloneURL *url.URL) (interface{}, error) {
	key := vcsstore.EncodeRepositoryPath(vcsType, cloneURL)

	t, err := c.TransportForRepository(vcsType, cloneURL)
	if err != nil {
		return nil, err
	}

	vc := vcsclient.New(nil, &http.Client{Transport: t})
	repo, err := vc.Repository(vcsType, cloneURL)
	if err != nil {
		return nil, err
	}
	return &repository{c.datad, key, repo, t}, nil
}
示例#3
0
func repoCmd(args []string) {
	fs := flag.NewFlagSet("repo", flag.ExitOnError)
	fs.Usage = func() {
		fmt.Fprintln(os.Stderr, `usage: vcsstore repo [options] repo-id

Displays the directory to which a repository would be cloned.

The options are:
`)
		fs.PrintDefaults()
		os.Exit(1)
	}
	fs.Parse(args)

	if fs.NArg() != 1 {
		fs.Usage()
	}

	repoPath := fs.Arg(0)

	fmt.Println("RepositoryPath:      ", filepath.Join(*storageDir, vcsstore.EncodeRepositoryPath(repoPath)))
	fmt.Println("URL:                 ", vcsclient.NewRouter(nil).URLToRepo(repoPath))
}
示例#4
0
func (c *Client) TransportForRepository(vcsType string, cloneURL *url.URL) (*datad.KeyTransport, error) {
	key := vcsstore.EncodeRepositoryPath(vcsType, cloneURL)
	return c.datad.TransportForKey(key, c.transport)
}