2019-09-07 04:47:18 -04:00
|
|
|
package repo
|
2017-01-03 22:27:20 -08:00
|
|
|
|
|
|
|
|
import (
|
2019-09-07 04:47:18 -04:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
|
2019-09-07 04:47:18 -04: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 == "" {
|
2019-09-07 04:47:18 -04:00
|
|
|
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 {
|
2019-09-07 04:47:18 -04:00
|
|
|
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,
|
|
|
|
|
}
|
2017-01-17 11:12:38 -08:00
|
|
|
gitGcCmd := common.NewShellCmd("git gc --aggressive")
|
2017-01-03 22:27:20 -08:00
|
|
|
gitGcCmd.Env = cmdEnv
|
|
|
|
|
gitGcCmd.Execute()
|
2019-09-07 04:47:18 -04:00
|
|
|
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
|
|
|
}
|