added '--full-clean' flag

This commit is contained in:
partisan 2024-12-16 21:24:35 +01:00
parent a21ff16308
commit 993bf58ecd
2 changed files with 22 additions and 15 deletions

View file

@ -79,28 +79,33 @@ func DiscardChanges(sourcePath string) {
}
// Function to clean build
func CleanBuild(sourcePath string) {
func CleanBuild(sourcePath string, fullClean bool) {
fmt.Println("Cleaning build...")
if err := os.Chdir(sourcePath); err != nil {
errors = append(errors, "Failed to navigate to source directory.")
return
}
// Use the appropriate mach command for Windows or Unix-like systems
var machCmd string
if runtime.GOOS == "windows" {
machCmd = ".\\mach"
} else {
machCmd = "./mach"
}
// Revert uncommitted changes
if err := runCommand("hg", "revert", "--all", "--no-backup"); err != nil {
errors = append(errors, "Failed to revert changes in Mozilla repository.")
}
// Clean the build
if err := runCommand(machCmd, "clobber"); err != nil {
errors = append(errors, "Failed to clean build.")
if fullClean {
// Perform full clean if specified
var machCmd string
if runtime.GOOS == "windows" {
machCmd = ".\\mach"
} else {
machCmd = "./mach"
}
if err := runCommand(machCmd, "clobber"); err != nil {
errors = append(errors, "Failed to clean build.")
}
} else {
fmt.Println("Skipping full clean. Build artifacts remain intact.")
}
}