-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from srijanone/Brownfield-Add-hooks-cmd
Added vega hooks install command for existing projects
- Loading branch information
Showing
14 changed files
with
186 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cmd | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func newHooksCmd(out io.Writer) *cobra.Command { | ||
const repoDesc = "manage git hooks" | ||
|
||
repoCmd := &cobra.Command{ | ||
Use: "hooks", | ||
Short: repoDesc, | ||
Long: repoDesc, | ||
} | ||
|
||
repoCmd.AddCommand(newHooksInstallCmd(out)) | ||
|
||
return repoCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
vega "github.com/srijanone/vega/pkg/core" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
type hooksInstallCmd struct { | ||
out io.Writer | ||
home vega.Home | ||
path string | ||
} | ||
|
||
func newHooksInstallCmd(out io.Writer) *cobra.Command { | ||
hInstallCmd := hooksInstallCmd{out: out} | ||
|
||
const hooksInstallDesc = "install git hooks in existing git repository" | ||
|
||
installCmd := &cobra.Command{ | ||
Use: "install [project-path]", | ||
Short: hooksInstallDesc, | ||
Long: hooksInstallDesc, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) == 0 { | ||
// If no arguments are passed, then choose current directory as path | ||
hInstallCmd.path = "." | ||
} else { | ||
hInstallCmd.path = args[0] | ||
} | ||
hInstallCmd.home = vega.Home(homePath()) | ||
hInstallCmd.execute() | ||
}, | ||
} | ||
|
||
return installCmd | ||
} | ||
|
||
func (hInstallCmd *hooksInstallCmd) execute() { | ||
fmt.Fprintf(hInstallCmd.out, "Installing git hooks to %s\n", hInstallCmd.path) | ||
|
||
// Adding Git Hooks to Vega Home | ||
gitHooks := vega.GitHooks{ | ||
Home: hInstallCmd.home, | ||
Out: hInstallCmd.out, | ||
} | ||
|
||
// Installing Git Hooks to project | ||
gitHooks.Install(hInstallCmd.path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters