-
-
Notifications
You must be signed in to change notification settings - Fork 52
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 #2218 from rsteube/git-maintenance
git: added maintenance
- Loading branch information
Showing
7 changed files
with
147 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var maintenanceCmd = &cobra.Command{ | ||
Use: "maintenance", | ||
Short: "Run tasks to optimize Git repository data", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
GroupID: groups[group_main].ID, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(maintenanceCmd).Standalone() | ||
|
||
rootCmd.AddCommand(maintenanceCmd) | ||
} |
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,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var maintenance_registerCmd = &cobra.Command{ | ||
Use: "register", | ||
Short: "Initialize Git config values", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(maintenance_registerCmd).Standalone() | ||
|
||
maintenanceCmd.AddCommand(maintenance_registerCmd) | ||
} |
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,27 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var maintenance_runCmd = &cobra.Command{ | ||
Use: "run", | ||
Short: "Start running maintenance on the current repository", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(maintenance_runCmd).Standalone() | ||
|
||
maintenance_runCmd.Flags().Bool("auto", false, "run tasks based on the state of the repository") | ||
maintenance_runCmd.Flags().Bool("quiet", false, "don't report progress or other information to stderr") | ||
maintenance_runCmd.Flags().Bool("schedule", false, "run tasks based on frequency") | ||
maintenance_runCmd.Flags().StringSlice("task", []string{}, "run a specific task") | ||
maintenanceCmd.AddCommand(maintenance_runCmd) | ||
|
||
carapace.Gen(maintenance_runCmd).FlagCompletion(carapace.ActionMap{ | ||
"task": git.ActionMaintenanceTasks(), | ||
}) | ||
} |
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,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var maintenance_startCmd = &cobra.Command{ | ||
Use: "start", | ||
Short: "Start running maintenance on the current repository", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(maintenance_startCmd).Standalone() | ||
|
||
maintenance_startCmd.Flags().String("scheduler", "", "specify scheduler") | ||
maintenanceCmd.AddCommand(maintenance_startCmd) | ||
|
||
carapace.Gen(maintenance_startCmd).FlagCompletion(carapace.ActionMap{ | ||
"scheduler": carapace.ActionValuesDescribed( | ||
"auto", "", | ||
"crontab", "POSIX", | ||
"systemd-timer", "Linux", | ||
"launchctl", "macOS", | ||
"schtasks", "Windows", | ||
), | ||
}) | ||
} |
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,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var maintenance_stopCmd = &cobra.Command{ | ||
Use: "stop", | ||
Short: "Halt the background maintenance schedule", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(maintenance_stopCmd).Standalone() | ||
|
||
maintenanceCmd.AddCommand(maintenance_stopCmd) | ||
} |
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,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var maintenance_unregisterCmd = &cobra.Command{ | ||
Use: "unregister", | ||
Short: "Remove the current repository from background maintenance", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(maintenance_unregisterCmd).Standalone() | ||
|
||
maintenanceCmd.AddCommand(maintenance_unregisterCmd) | ||
} |
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,18 @@ | ||
package git | ||
|
||
import "github.com/rsteube/carapace" | ||
|
||
// ActionMaintenanceTasks completes maintenance tasks | ||
// | ||
// commit-graph (Update the commit-graph files incrementally) | ||
// prefetch (Updates the object directory with the latest objects from all registered remotes) | ||
func ActionMaintenanceTasks() carapace.Action { | ||
return carapace.ActionValuesDescribed( | ||
"commit-graph", "Update the commit-graph files incrementally", | ||
"prefetch", "Updates the object directory with the latest objects from all registered remotes", | ||
"gc", "Clean up unnecessary files and optimize the local repository", | ||
"loose-objects", "Clean up loose objects and places them into pack-files", | ||
"incremental-repack", "Repack the object directory using the multi-pack-index feature", | ||
"pack-refs", "Collect the loose reference files and collects them into a single file", | ||
) | ||
} |