Add a --write and --diff flag; require --write to be set before making any changes, for safety
This commit is contained in:
@@ -110,7 +110,7 @@ type TemporalInterval struct {
|
||||
EndExclusive string `json:"end_exclusive"`
|
||||
}
|
||||
|
||||
func generateHTML(yamlFile string) {
|
||||
func generateHTML(yamlFile string, wantDiff bool, allowWrite bool, useColor bool) {
|
||||
config := loadConfig(yamlFile)
|
||||
|
||||
// Check that all local directories exist
|
||||
@@ -145,14 +145,14 @@ func generateHTML(yamlFile string) {
|
||||
}
|
||||
|
||||
// Write file with status
|
||||
err = writeFileWithStatus(indexPath, buf.Bytes())
|
||||
err = writeFileWithStatus(indexPath, buf.Bytes(), wantDiff, allowWrite, useColor)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to write HTML to %s: %v", indexPath, err)
|
||||
}
|
||||
|
||||
// Generate log.v3.json for this log
|
||||
jsonPath := filepath.Join(logEntry.LocalDirectory, "log.v3.json")
|
||||
err = generateLogJSONWithStatus(logEntry, jsonPath)
|
||||
err = generateLogJSONWithStatus(logEntry, jsonPath, wantDiff, allowWrite, useColor)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to generate %s: %v", jsonPath, err)
|
||||
}
|
||||
@@ -209,7 +209,7 @@ func computeKeyInfo(logEntry *Log) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateLogJSONWithStatus(logEntry Log, outputPath string) error {
|
||||
func generateLogJSONWithStatus(logEntry Log, outputPath string, wantDiff bool, allowWrite bool, useColor bool) error {
|
||||
logJSON := LogV3JSON{
|
||||
Description: fmt.Sprintf("%s.log.ct.ipng.ch", logEntry.ShortName),
|
||||
SubmissionURL: fmt.Sprintf("%s/", logEntry.SubmissionPrefix),
|
||||
@@ -228,5 +228,5 @@ func generateLogJSONWithStatus(logEntry Log, outputPath string) error {
|
||||
return fmt.Errorf("failed to marshal JSON: %v", err)
|
||||
}
|
||||
|
||||
return writeFileWithStatus(outputPath, jsonData)
|
||||
return writeFileWithStatus(outputPath, jsonData, wantDiff, allowWrite, useColor)
|
||||
}
|
||||
|
Reference in New Issue
Block a user