Documentation
¶
Index ¶
- func CreateTarball(records []CommitRecord, meta ArchiveMetadata) (string, error)
- func FindTarEntry(t *testing.T, files map[string]string, suffix string) string
- func HasTarEntry(files map[string]string, suffix string) bool
- func ReadTarball(t *testing.T, path string) map[string]string
- type ArchiveMetadata
- type CommitRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTarball ¶
func CreateTarball(records []CommitRecord, meta ArchiveMetadata) (string, error)
CreateTarball writes a tar.gz to a temp file containing:
- <dir>/commit-metadata.jsonl (one JSON object per line)
- <dir>/metadata.json (archive metadata)
Files are nested inside a directory named backfill-<org>-<suite>-<timestamp> to follow tar best practices (no top-level files).
Returns the path to the temp file. Caller is responsible for cleanup. The temp file is renamed to include a timestamp on success for easier identification if cleanup is skipped.
func FindTarEntry ¶
FindTarEntry returns the content of the first entry whose name ends with the given suffix. Fails the test if no match is found.
func HasTarEntry ¶
HasTarEntry returns true if any entry name ends with the given suffix.
Types ¶
type ArchiveMetadata ¶
type ArchiveMetadata struct {
SchemaVersion int `json:"schema_version"`
Tool string `json:"tool"`
ToolVersion string `json:"tool_version"`
GeneratedAt string `json:"generated_at"`
OrganizationSlug string `json:"organization_slug"`
SuiteSlug string `json:"suite_slug"`
CommitCount int `json:"commit_count"`
SkippedCommits int `json:"skipped_commits"`
// Config options used for this export
Days int `json:"days"`
Remote string `json:"remote"`
SkippedDiffs bool `json:"skipped_diffs"`
// Date range of commits in the archive (ISO 8601, from CommitterDate)
MinCommitDate string `json:"min_commit_date,omitempty"`
MaxCommitDate string `json:"max_commit_date,omitempty"`
}
ArchiveMetadata is the metadata written to metadata.json in the tarball.
type CommitRecord ¶
type CommitRecord struct {
SchemaVersion int `json:"schema_version"`
CommitSHA string `json:"commit_sha"`
ParentSHAs []string `json:"parent_shas"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
AuthorDate string `json:"author_date"`
CommitterName string `json:"committer_name"`
CommitterEmail string `json:"committer_email"`
CommitterDate string `json:"committer_date"`
Message string `json:"message"`
FilesChanged string `json:"files_changed"`
DiffStat string `json:"diff_stat"`
GitDiff string `json:"git_diff,omitempty"`
GitDiffRaw string `json:"git_diff_raw,omitempty"`
}
CommitRecord is the per-commit record written to the JSONL file.