Files
dokku/plugins/repo/subcommands.go

38 lines
862 B
Go
Raw Normal View History

package repo
2017-01-03 22:27:20 -08:00
import (
"errors"
2017-01-03 22:27:20 -08:00
"strings"
2017-10-02 16:50:05 -07:00
"github.com/dokku/dokku/plugins/common"
2017-01-03 22:27:20 -08:00
)
// CommandGc runs 'git gc --aggressive' against the application's repo
func CommandGc(appName string) error {
2017-01-03 22:27:20 -08:00
if appName == "" {
return errors.New("Please specify an app to run the command on")
2017-01-03 22:27:20 -08:00
}
err := common.VerifyAppName(appName)
if err != nil {
return err
2017-01-03 22:27:20 -08:00
}
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
cmdEnv := map[string]string{
"GIT_DIR": appRoot,
}
gitGcCmd := common.NewShellCmd("git gc --aggressive")
2017-01-03 22:27:20 -08:00
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 appName == "" {
common.LogFail("Please specify an app to run the command on")
}
return PurgeCache(appName)
2017-01-03 22:27:20 -08:00
}