Files
dokku/plugins/repo/subcommands.go
Jose Diaz-Gonzalez ffa303092f feat: add app name verification to all golang plugins
Moving verification of input to the earliest place is the best way to decrease the need to validate this further downstream.

Additionally, some of the existing checks were.... lacking :)
2020-12-27 15:14:11 -05:00

31 lines
688 B
Go

package repo
import (
"github.com/dokku/dokku/plugins/common"
)
// CommandGc runs 'git gc --aggressive' against the application's repo
func CommandGc(appName string) error {
if err := common.VerifyAppName(appName); err != nil {
return err
}
appRoot := common.AppRoot(appName)
cmdEnv := map[string]string{
"GIT_DIR": appRoot,
}
gitGcCmd := common.NewShellCmd("git gc --aggressive")
gitGcCmd.Env = cmdEnv
gitGcCmd.Execute()
return nil
}
// CommandPurgeCache deletes the contents of the build cache stored in the repository
func CommandPurgeCache(appName string) error {
if err := common.VerifyAppName(appName); err != nil {
return err
}
return PurgeCache(appName)
}