func MitreSync()

in ci/internal/cli/mitresync.go [28:63]


func MitreSync(stdout io.Writer, args []string) int {
	start := time.Now()

	flags, err := parseFlags(stdout, args)
	if err != nil {
		return exitError
	}

	ctx := context.Background()
	initLogger(stdout, flags)

	if flags.sinceCommit == "" {
		return fatal("since commit is empty or not set", nil)
	}

	repo, err := git.NewRepository(flags.repo)
	if err != nil {
		return fatal("error initializing repository", err, "path", flags.repo)
	}

	slog.Info("starting mitresync", "time", time.Now().UTC().Format(time.RFC1123Z), "sinceCommit", flags.sinceCommit, "repo", repo.Dir())
	slog.Debug("debugging enabled")

	if flags.dryrun {
		slog.Warn("DRY RUN ENABLED: data changing actions will not be performed")
	}

	if err := processModified(ctx, repo, flags.sinceCommit, flags); err != nil {
		slog.Warn("finished with errors", "dur", time.Since(start).Round(time.Millisecond))
		return exitError
	}

	slog.Info("finished with no errors", "dur", time.Since(start).Round(time.Millisecond))

	return exitNormal
}