Esempio n. 1
0
func (p *PackageManager) Get(localPath string) (string, error) {
	fullPath := p.path + localPath
	record, exists := p.Repositories[localPath]
	if !exists {
		return "", fmt.Errorf("Record for \""+localPath+"\" path not exist %v", p.Repositories)
	}
	if !disk.IsExist(fullPath) {
		if err := p.load(fullPath, record.Url, record.Rev); err != nil {
			return "", err
		}
	}
	return fullPath, nil
}
Esempio n. 2
0
func (p *PackageManager) load(fullPath, url, rev string) error {
	if disk.IsExist(fullPath) {
		return fmt.Errorf("Directory " + fullPath + " exist")
	}
	repo := NewRepository(fullPath)
	if err := repo.Clone(url); err != nil {
		return err
	}
	if rev != "" {
		if err := repo.Checkout(rev); err != nil {
			return err
		}
	}
	return nil
}
Esempio n. 3
0
func (p *PackageManager) update(localPath string, record RepositoryPackage) error {
	fullPath := p.path + localPath
	if !disk.IsExist(fullPath) {
		if err := p.load(fullPath, record.Url, record.Rev); err != nil {
			return err
		}
	} else {
		repo := NewRepository(fullPath)
		if err := repo.Pull(); err != nil {
			return err
		}
		if record.Rev != "" {
			if err := repo.Checkout(record.Rev); err != nil {
				return err
			}
		}
	}
	return nil
}
Esempio n. 4
0
func (fs *Filespace) IsExist(subPath string) bool {
	return disk.IsExist(fs.path + subPath)
}