forked from toolshed/abra
		
	
							
								
								
									
										14
									
								
								pkg/git/common.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								pkg/git/common.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| package git | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| ) | ||||
|  | ||||
| // EnsureGitRepo ensures a git repo .git folder exists | ||||
| func EnsureGitRepo(repoPath string) error { | ||||
| 	if _, err := os.Stat(repoPath); os.IsNotExist(err) { | ||||
| 		return fmt.Errorf("no .git directory in %s?", repoPath) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| @ -108,6 +108,10 @@ func EnsureExists(recipe string) error { | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if err := gitPkg.EnsureGitRepo(recipeDir); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| @ -124,6 +128,10 @@ func EnsureVersion(recipeName, version string) error { | ||||
| 		return fmt.Errorf("'%s' has locally unstaged changes", recipeName) | ||||
| 	} | ||||
|  | ||||
| 	if err := gitPkg.EnsureGitRepo(recipeDir); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	repo, err := git.PlainOpen(recipeDir) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| @ -184,6 +192,10 @@ func EnsureLatest(recipeName string) error { | ||||
| 		return fmt.Errorf("'%s' has locally unstaged changes", recipeName) | ||||
| 	} | ||||
|  | ||||
| 	if err := gitPkg.EnsureGitRepo(recipeDir); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	logrus.Debugf("attempting to open git repository in '%s'", recipeDir) | ||||
|  | ||||
| 	repo, err := git.PlainOpen(recipeDir) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user