metadata

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package metadata exports the parts of GitHub that live outside git (issues, pull requests, releases, settings, projects, ...) as JSON files next to the repos.

Index

Constants

View Source
const (
	IssuesFile   = "issues.json"
	PullsFile    = "pulls.json"
	ReleasesFile = "releases.json"
	RulesetsFile = "rulesets.json"
)

Files written per repo; verify reads the issue and pull counts back

Variables

View Source
var (
	OrgFiles  = []string{"org.json", "actions-variables.json", "actions-secrets.json", "members.json", "teams.json", "projects-v2.json", RulesetsFile}
	UserFiles = []string{"projects-v2.json"}
)

OrgFiles and UserFiles are the files an org or user export writes; verify checks them

Functions

func AssetPath

func AssetPath(metaDir string, release *gh.RepositoryRelease, asset *gh.ReleaseAsset) string

AssetPath returns where a release asset is stored under a repo's metadata dir

func OwnerDir

func OwnerDir(target, login string) string

OwnerDir returns where an org's or user's metadata lives under target

func RepoDir

func RepoDir(target, owner, repo string) string

RepoDir returns where a repo's metadata lives under target

Types

type Discussion

type Discussion struct {
	ID        string                        `json:"id"`
	Number    int                           `json:"number"`
	Title     string                        `json:"title"`
	Body      string                        `json:"body"`
	URL       string                        `json:"url"`
	CreatedAt string                        `json:"createdAt"`
	UpdatedAt string                        `json:"updatedAt"`
	Closed    bool                          `json:"closed"`
	Locked    bool                          `json:"locked"`
	Author    json.RawMessage               `json:"author"`
	Category  json.RawMessage               `json:"category"`
	Labels    json.RawMessage               `json:"labels"`
	Comments  connection[DiscussionComment] `json:"comments"`
}

Discussion is a repo discussion with all its comments and replies

type DiscussionComment

type DiscussionComment struct {
	ID        string                      `json:"id"`
	Body      string                      `json:"body"`
	URL       string                      `json:"url"`
	CreatedAt string                      `json:"createdAt"`
	UpdatedAt string                      `json:"updatedAt"`
	IsAnswer  bool                        `json:"isAnswer"`
	Author    json.RawMessage             `json:"author"`
	Replies   connection[json.RawMessage] `json:"replies"`
}

DiscussionComment is a top-level discussion comment with its replies

type Exporter

type Exporter struct {

	// Verbose prints each file as it is written
	Verbose bool
	// contains filtered or unexported fields
}

Exporter writes metadata JSON files under a target directory

func New

func New(client *gh.Client, download *http.Client, target string) *Exporter

New returns an Exporter. download fetches release assets from the storage host GitHub redirects to, so it must not carry the token.

func (*Exporter) ExportOrg

func (e *Exporter) ExportOrg(ctx context.Context, org string, rep *Report)

ExportOrg writes an org's settings, Actions variables, secret names, members, teams, projects and rulesets into <target>/<org>.meta

func (*Exporter) ExportRepo

func (e *Exporter) ExportRepo(ctx context.Context, repo *gh.Repository, rep *Report)

ExportRepo writes all metadata of one repo into <target>/<owner>/<repo>.meta

func (*Exporter) ExportUser

func (e *Exporter) ExportUser(ctx context.Context, login string, rep *Report)

ExportUser writes a user's projects into <target>/<login>.meta

type IssueExport

type IssueExport struct {
	Issue    *gh.Issue          `json:"issue"`
	Comments []*gh.IssueComment `json:"comments"`
}

IssueExport is an issue with its comments

type Project

type Project struct {
	ID               string                      `json:"id"`
	Number           int                         `json:"number"`
	Title            string                      `json:"title"`
	ShortDescription string                      `json:"shortDescription"`
	Readme           string                      `json:"readme"`
	URL              string                      `json:"url"`
	Public           bool                        `json:"public"`
	Closed           bool                        `json:"closed"`
	CreatedAt        string                      `json:"createdAt"`
	UpdatedAt        string                      `json:"updatedAt"`
	Fields           connection[json.RawMessage] `json:"fields"`
	Items            []json.RawMessage           `json:"items"`
}

Project is a Projects (v2) board with its fields and every item

type PullExport

type PullExport struct {
	Pull           *gh.PullRequest          `json:"pull"`
	Comments       []*gh.IssueComment       `json:"comments"`
	ReviewComments []*gh.PullRequestComment `json:"review_comments"`
	Reviews        []*gh.PullRequestReview  `json:"reviews"`
}

PullExport is a pull request with its conversation, review comments and reviews

type Report

type Report struct {
	// Exported names every repo, org or user whose metadata was written
	Exported []string
	// Warnings are parts skipped because the token lacks a scope or access
	Warnings []string
	// Failed holds real failures, keyed by repo, org or user
	Failed map[string]error
}

Report collects what an export did

func NewReport

func NewReport() *Report

NewReport returns an empty report

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL