Skip to content
@deckyard/forgejo

forgejo cheatsheet

Every export of @deckyard/forgejo. Guides are listed in the introduction.

jennifer
import "@deckyard/forgejo/" as forgejo;

Every function that sends a request throws Error{kind: "forgejo"} when it fails. A repo is owner/name; a number is an issue or pull request number.

Constants

ConstantValueMeaning
ERROR_KIND"forgejo"the kind of every error the deck throws
PAGE_SIZE50entries asked for per page
MAX_PAGES1000pages a list follows before it refuses
MERGE_STYLES["merge", "rebase", "rebase-merge", "squash", "fast-forward-only"]the ways to merge a pull request

Types

Client

FieldMeaning
url as stringhttps://host, without /api/v1
token as stringthe access token; "" for anonymous reads
tls as http.TlsOptionscertificate checking
timeoutMs as intidle timeout per request; 0 for 30 s
retries as intretries of a GET answered 429 or 5xx

User

FieldMeaning
id as intthe account id
login as stringthe user name
fullName as stringthe display name
email as stringthe e-mail address, as far as the token may see it
isAdmin as boolwhether it administers the instance

Repository

FieldMeaning
id as intthe repository id
owner as stringthe owning user or organization
name as stringthe name
fullName as stringowner/name
description as stringthe description
isPrivate as boolwhether it is private
isFork as boolwhether it is a fork
isArchived as boolwhether it is archived
defaultBranch as stringe.g. main
htmlUrl as stringits page
cloneUrl as stringthe HTTPS clone URL
sshUrl as stringthe SSH clone URL
stars as intthe star count
openIssues as intopen issues
updated as stringlast update, RFC 3339

Issue

FieldMeaning
number as intthe number within the repository
title as stringthe title
body as stringthe text, Markdown
state as stringopen or closed
author as stringwho opened it
labels as list of stringlabel names
assignees as list of stringassigned user names
comments as intthe comment count
isPull as boolwhether it is a pull request
created as stringRFC 3339
updated as stringRFC 3339
closed as stringRFC 3339; "" while open
htmlUrl as stringits page

Comment

FieldMeaning
id as intthe comment id
author as stringwho wrote it
body as stringthe text, Markdown
created as stringRFC 3339
htmlUrl as stringits place on the page

PullRequest

FieldMeaning
number as intthe number within the repository
title as stringthe title
body as stringthe text, Markdown
state as stringopen or closed
author as stringwho opened it
head as stringthe branch with the changes
base as stringthe branch it merges into
headSha as stringthe commit at the head
isDraft as boolwhether it is a draft
mergeable as boolwhether Forgejo can merge it
merged as boolwhether it is merged
mergeSha as stringthe merge commit; "" until merged
htmlUrl as stringits page

Asset

FieldMeaning
id as intthe asset id
name as stringthe file name
size as intbytes
downloads as intthe download count
downloadUrl as stringwhere it downloads from

Release

FieldMeaning
id as intthe release id
tag as stringthe tag it is for
name as stringthe title
body as stringthe notes, Markdown
isDraft as boolwhether it is a draft
isPrerelease as boolwhether it is a pre-release
created as stringRFC 3339
published as stringRFC 3339
htmlUrl as stringits page
assets as list of Assetthe attached files

Branch

FieldMeaning
name as stringthe name
sha as stringthe commit it points at
isProtected as boolwhether a protection rule covers it

Tag

FieldMeaning
name as stringthe name
sha as stringthe commit it points at
message as stringthe annotation; "" for a lightweight tag

CommitStatus

FieldMeaning
context as stringwhich check, e.g. ci/build
state as stringpending, success, error, failure or warning
description as stringa short text
targetUrl as stringwhere the details are
creator as stringwho set it
created as stringRFC 3339

CombinedStatus

FieldMeaning
state as stringthe worst latest state; "" without statuses
statuses as list of CommitStatusthe latest status per context

Commit

FieldMeaning
sha as stringthe commit SHA
message as stringthe commit message
author as stringthe author's name
authorEmail as stringthe author's e-mail address
date as stringthe author date, RFC 3339
htmlUrl as stringits page

Label

FieldMeaning
id as intthe label id
name as stringe.g. bug, scope/ui
color as stringe.g. #ee0701
description as stringthe description
exclusive as boolwhether it excludes the rest of its scope

Milestone

FieldMeaning
id as intthe milestone id
title as stringthe title
description as stringthe description
state as stringopen or closed
dueOn as stringRFC 3339; "" without a due date
openIssues as intopen issues in it
closedIssues as intclosed issues in it

Review

FieldMeaning
id as intthe review id
author as stringwho reviewed
state as stringAPPROVED, REQUEST_CHANGES, COMMENT, PENDING or REQUEST_REVIEW
body as stringthe text, Markdown
commitId as stringthe commit it reviewed
submitted as stringRFC 3339

ChangedFile

FieldMeaning
filename as stringthe path
status as stringe.g. added, changed, deleted, renamed
additions as intlines added
deletions as intlines deleted
previousFilename as stringthe old path of a renamed file

Hook

FieldMeaning
id as intthe hook id
type as stringe.g. forgejo, slack
url as stringwhere it posts to
events as list of stringe.g. push
active as boolwhether it fires

Entry

FieldMeaning
name as stringthe name
path as stringthe path from the root
type as stringfile, dir, symlink or submodule
size as intbytes; 0 for a directory
sha as stringthe blob or tree SHA

Connecting

FunctionReturnsDoes
forgejo.client(address)Clienta client for an instance, without a token
forgejo.withToken(c, token)Clientauthenticate with an access token
forgejo.withCaCert(c, pem)Clienttrust a certificate
forgejo.withInsecure(c)Clientaccept any certificate
forgejo.withTimeout(c, ms)Clientset the idle timeout
forgejo.withRetries(c, n)Clientretry GETs answered 429 or 5xx
forgejo.call(c, method, path, body)json.Valueany endpoint; body is JSON text
forgejo.getAll(c, path)list of json.Valueevery page of a list endpoint
forgejo.version(c)stringthe instance's version
forgejo.currentUser(c)Userthe token's account

Repositories

FunctionReturnsDoes
forgejo.repository(c, repo)Repositoryone repository
forgejo.repositories(c, owner)list of Repositorya user's or organization's repositories
forgejo.myRepositories(c)list of Repositorythe token's own and shared repositories
forgejo.createRepository(c, owner, name, description, isPrivate)Repositoryan empty repository; owner "" for the token's account
forgejo.deleteRepository(c, repo)delete it, with no undo
forgejo.editRepository(c, repo, description, website)Repositorychange them; "" keeps
forgejo.setArchived(c, repo, archived)Repositoryarchive it or bring it back
forgejo.setDefaultBranch(c, repo, branch)Repositorychange the default branch
forgejo.forkRepository(c, repo, organization, name)Repositoryfork it; "" for your account, the same name
forgejo.searchRepositories(c, query)list of Repositorysearch names and descriptions
forgejo.collaborators(c, repo)list of Userthe collaborators
forgejo.addCollaborator(c, repo, name, permission)read, write or admin
forgejo.removeCollaborator(c, repo, name)remove one
forgejo.hooks(c, repo)list of Hookthe webhooks
forgejo.createHook(c, repo, url, secret, events)Hooka Forgejo webhook posting JSON
forgejo.deleteHook(c, repo, id)delete one
forgejo.branches(c, repo)list of Branchthe branches
forgejo.tags(c, repo)list of Tagthe tags, newest first
forgejo.createBranch(c, repo, name, from)Branchbranch off a ref; "" for the default branch
forgejo.deleteBranch(c, repo, name)delete a branch
forgejo.createTag(c, repo, name, target, message)Tagtag a ref; "" message for a lightweight tag
forgejo.deleteTag(c, repo, name)delete a tag
forgejo.readFile(c, repo, path, ref)bytesa file at a ref, LFS content included; "" for the default branch
forgejo.writeFile(c, repo, path, data, message, branch)stringcommit a file; the commit SHA
forgejo.deleteFile(c, repo, path, message, branch)stringdelete a file; the commit SHA
forgejo.listDirectory(c, repo, path, ref)list of Entrya directory's entries; "" for the root

Issues and pull requests

FunctionReturnsDoes
forgejo.issues(c, repo, state)list of Issueissues, without pull requests
forgejo.issue(c, repo, number)Issueone issue
forgejo.createIssue(c, repo, title, body)Issueopen an issue
forgejo.closeIssue(c, repo, number)Issueclose an issue or pull request
forgejo.reopenIssue(c, repo, number)Issuereopen one
forgejo.comments(c, repo, number)list of Commentits comments, oldest first
forgejo.comment(c, repo, number, body)Commentadd a comment
forgejo.editComment(c, repo, id, body)Commentchange a comment
forgejo.deleteComment(c, repo, id)delete a comment
forgejo.editIssue(c, repo, number, title, body)Issuechange title or text; "" keeps
forgejo.setAssignees(c, repo, number, names)Issueset who is assigned
forgejo.setMilestone(c, repo, number, milestoneId)Issueput it in a milestone; 0 for none
forgejo.labels(c, repo)list of Labelthe repository's labels
forgejo.createLabel(c, repo, name, color, description)Labelcreate a label
forgejo.deleteLabel(c, repo, id)delete a label
forgejo.setIssueLabels(c, repo, number, names)list of Labelreplace its labels
forgejo.addIssueLabels(c, repo, number, names)list of Labeladd labels
forgejo.removeIssueLabel(c, repo, number, name)take a label off
forgejo.milestones(c, repo, state)list of Milestonethe milestones
forgejo.createMilestone(c, repo, title, description, dueOn)Milestonecreate one
forgejo.setMilestoneClosed(c, repo, id, closed)Milestoneclose or reopen one
forgejo.deleteMilestone(c, repo, id)delete one
forgejo.pullRequests(c, repo, state)list of PullRequestpull requests
forgejo.pullRequest(c, repo, number)PullRequestone pull request
forgejo.createPullRequest(c, repo, head, base, title, body)PullRequestopen a pull request
forgejo.mergePullRequest(c, repo, number, style, deleteBranch)merge it
forgejo.editPullRequest(c, repo, number, title, body)PullRequestchange title or text; "" keeps
forgejo.reviewPullRequest(c, repo, number, event, body)ReviewAPPROVED, REQUEST_CHANGES or COMMENT
forgejo.reviews(c, repo, number)list of Reviewits reviews
forgejo.requestReviewers(c, repo, number, names)ask users to review
forgejo.pullRequestFiles(c, repo, number)list of ChangedFilethe files it changes

Releases

FunctionReturnsDoes
forgejo.releases(c, repo)list of Releasethe releases, newest first
forgejo.release(c, repo, tag)Releasethe release of a tag
forgejo.latestRelease(c, repo)Releasethe newest that is no draft or pre-release
forgejo.editRelease(c, repo, id, name, body)Releasechange title or notes; "" keeps
forgejo.createRelease(c, repo, tag, target, name, body, isPrerelease)Releasepublish a release
forgejo.deleteRelease(c, repo, id)delete it; the tag stays
forgejo.uploadAsset(c, repo, releaseId, name, data)Assetattach a file
forgejo.downloadAsset(c, asset, maxBytes)bytesdownload a file from the instance
forgejo.deleteAsset(c, repo, releaseId, assetId)delete an attached file

Commits and CI

FunctionReturnsDoes
forgejo.commits(c, repo, ref, path)list of Commitcommits from a ref; path narrows them
forgejo.commit(c, repo, sha)Commitone commit
forgejo.setCommitStatus(c, repo, sha, state, context, description, targetUrl)CommitStatusreport a check on a commit
forgejo.commitStatuses(c, repo, ref)list of CommitStatusevery status set on it
forgejo.combinedStatus(c, repo, ref)CombinedStatusthe latest per check, and the worst
forgejo.dispatchWorkflow(c, repo, workflow, ref, inputs)intrun a workflow; the run id
forgejo.setSecret(c, repo, name, value)create or replace an Actions secret
forgejo.deleteSecret(c, repo, name)delete one
forgejo.variables(c, repo)map of string to stringthe Actions variables
forgejo.setVariable(c, repo, name, value)create or replace one
forgejo.deleteVariable(c, repo, name)delete one