Documentation ¶
Index ¶
- Constants
- type Accessor
- type DefaultAccessor
- func (accessor *DefaultAccessor) AddIssue(issue *Issue) (int64, error)
- func (accessor *DefaultAccessor) AddIssueAssignee(issueID int64, assigneeID int64) error
- func (accessor *DefaultAccessor) AddIssueAttachment(issueID int64, attachment *IssueAttachment, filePath string) (int64, error)
- func (accessor *DefaultAccessor) AddIssueComment(issueID int64, comment *IssueComment) (int64, error)
- func (accessor *DefaultAccessor) AddIssueLabel(issueID int64, labelID int64) (int64, error)
- func (accessor *DefaultAccessor) AddIssueParticipant(issueID int64, userID int64) error
- func (accessor *DefaultAccessor) AddLabel(label *Label) (int64, error)
- func (accessor *DefaultAccessor) AddMilestone(milestone *Milestone) (int64, error)
- func (accessor *DefaultAccessor) CloneWiki() error
- func (accessor *DefaultAccessor) CommitTransaction() error
- func (accessor *DefaultAccessor) CommitWikiToRepo(author string, authorEMail string, message string) error
- func (accessor *DefaultAccessor) CopyFileToWiki(externalFilePath string, giteaWikiRelPath string) error
- func (accessor *DefaultAccessor) GetCommitURL(commitID string) string
- func (accessor *DefaultAccessor) GetIssueAttachmentURL(issueID int64, uuid string) string
- func (accessor *DefaultAccessor) GetIssueAttachmentUUID(issueID int64, fileName string) (string, error)
- func (accessor *DefaultAccessor) GetIssueCommentIDsByTime(issueID int64, createdTime int64) ([]int64, error)
- func (accessor *DefaultAccessor) GetIssueCommentURL(issueID int64, commentID int64) string
- func (accessor *DefaultAccessor) GetIssueID(issueIndex int64) (int64, error)
- func (accessor *DefaultAccessor) GetIssueURL(issueID int64) string
- func (accessor *DefaultAccessor) GetLabelID(labelName string) (int64, error)
- func (accessor *DefaultAccessor) GetMilestoneID(milestoneName string) (int64, error)
- func (accessor *DefaultAccessor) GetMilestoneURL(milestoneID int64) string
- func (accessor *DefaultAccessor) GetSourceURL(branchPath string, filePath string) string
- func (accessor *DefaultAccessor) GetStringConfig(sectionName string, configName string) string
- func (accessor *DefaultAccessor) GetUserEMailAddress(userName string) (string, error)
- func (accessor *DefaultAccessor) GetUserID(userName string) (int64, error)
- func (accessor *DefaultAccessor) GetWikiAttachmentRelPath(pageName string, filename string) string
- func (accessor *DefaultAccessor) GetWikiFileURL(relpath string) string
- func (accessor *DefaultAccessor) GetWikiHtdocRelPath(filename string) string
- func (accessor *DefaultAccessor) MatchUser(userName string, userEmail string) (string, error)
- func (accessor *DefaultAccessor) RollbackTransaction() error
- func (accessor *DefaultAccessor) SetIssueUpdateTime(issueID int64, updateTime int64) error
- func (accessor *DefaultAccessor) TranslateWikiPageName(pageName string) string
- func (accessor *DefaultAccessor) UpdateIssueCommentCount(issueID int64) error
- func (accessor *DefaultAccessor) UpdateLabelIssueCounts() error
- func (accessor *DefaultAccessor) UpdateMilestoneIssueCounts() error
- func (accessor *DefaultAccessor) UpdateRepoIssueCounts() error
- func (accessor *DefaultAccessor) UpdateRepoMilestoneCounts() error
- func (accessor *DefaultAccessor) WriteWikiPage(pageName string, markdownText string, commitMarker string) (bool, error)
- type Issue
- type IssueAttachment
- type IssueComment
- type IssueCommentType
- type Label
- type Milestone
Constants ¶
const NullID = int64(0)
NullID id for unset references in Gitea, also used for lookup failures
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accessor ¶
type Accessor interface { /* * Configuration */ // GetStringConfig retrieves a value from the Gitea config as a string. GetStringConfig(sectionName string, configName string) string /* * Issues */ // GetIssueID retrieves the id of the Gitea issue corresponding to a given index - returns NullID if no such issue. GetIssueID(issueIndex int64) (int64, error) // AddIssue adds a new issue to Gitea - returns id of created issue. AddIssue(issue *Issue) (int64, error) // SetIssueUpdateTime sets the update time on a given Gitea issue. SetIssueUpdateTime(issueID int64, updateTime int64) error // GetIssueURL retrieves a URL for viewing a given issue GetIssueURL(issueID int64) string // UpdateIssueCommentCount updates the count of comments a given issue UpdateIssueCommentCount(issueID int64) error /* * Issue Assignees */ // AddIssueAssignee adds an assignee to a Gitea issue AddIssueAssignee(issueID int64, assigneeID int64) error /* * Issue Attachments */ // GetIssueAttachmentUUID returns the UUID for a named attachment of a given issue - returns empty string if cannot find issue/attachment. GetIssueAttachmentUUID(issueID int64, fileName string) (string, error) // AddIssueAttachment adds a new attachment to an issue using the provided file - returns id of created attachment AddIssueAttachment(issueID int64, attachment *IssueAttachment, filePath string) (int64, error) // GetIssueAttachmentURL retrieves the URL for viewing a Gitea attachment GetIssueAttachmentURL(issueID int64, uuid string) string /* * Issue Comments */ // GetIssueCommentIDsByTime retrieves the IDs of all comments created at a given time for a given issue GetIssueCommentIDsByTime(issueID int64, createdTime int64) ([]int64, error) // AddIssueComment adds a comment on a Gitea issue, returns id of created comment AddIssueComment(issueID int64, comment *IssueComment) (int64, error) // GetIssueCommentURL retrieves the URL for viewing a Gitea comment for a given issue. GetIssueCommentURL(issueID int64, commentID int64) string /* * Issue Labels */ // AddIssueLabel adds an issue label to Gitea, returns issue label ID AddIssueLabel(issueID int64, labelID int64) (int64, error) // UpdateLabelIssueCounts updates issue counts for all labels. UpdateLabelIssueCounts() error /* * Issue Milestones */ // UpdateMilestoneIssueCounts updates issue counts for all milestones. UpdateMilestoneIssueCounts() error /* * Issue Participants */ // AddIssueParticipant adds a user as a participant in a Gitea issue AddIssueParticipant(issueID int64, userID int64) error /* * Labels */ // GetLabelID retrieves the id of the given label, returns NullID if no such label GetLabelID(labelName string) (int64, error) // AddLabel adds a label to Gitea, returns label id. AddLabel(label *Label) (int64, error) /* * Milestones */ // GetMilestoneID gets the ID of a named milestone - returns NullID if no such milestone GetMilestoneID(name string) (int64, error) // AddMilestone adds a milestone to Gitea, returns id of created milestone AddMilestone(milestone *Milestone) (int64, error) // GetMilestoneURL gets the URL for accessing a given milestone GetMilestoneURL(milestoneID int64) string /* * Repository */ // UpdateRepoIssueCounts updates issue counts for our chosen Gitea repository. UpdateRepoIssueCounts() error // UpdateRepoMilestoneCounts updates milestone counts for our chosen Gitea repository. UpdateRepoMilestoneCounts() error // GetCommitURL retrieves the URL for viewing a given commit in the current repository GetCommitURL(commitID string) string // GetSourceURL retrieves the URL for viewing the latest version of a source file on a given branch of the current repository GetSourceURL(branchPath string, filePath string) string /* * Transactions * - a transaction is started on creation of the accessor */ // CommitTransaction commits a Gitea transaction. CommitTransaction() error // RollbackTransaction rolls back a Gitea transaction. RollbackTransaction() error /* * Users */ // GetUserID retrieves the id of a named Gitea user - returns NullID if no such user. GetUserID(userName string) (int64, error) // GetUserEMailAddress retrieves the email address of a given user GetUserEMailAddress(userName string) (string, error) // MatchUser retrieves the name of the user best matching a user name or email address MatchUser(userName string, userEmail string) (string, error) /* * Wiki */ // GetWikiAttachmentRelPath returns the location of an attachment to Trac a wiki page when stored in the Gitea wiki repository. // The returned path is relative to the root of the Gitea wiki repository. GetWikiAttachmentRelPath(pageName string, filename string) string // GetWikiHtdocRelPath returns the location of a given Trac 'htdocs' file when stored in the Gitea wiki repository. // The returned path is relative to the root of the Gitea wiki repository. GetWikiHtdocRelPath(filename string) string // GetWikiFileURL returns a URL for viewing a file stored in the Gitea wiki repository. GetWikiFileURL(relpath string) string // CloneWiki creates a local clone of the wiki repo. CloneWiki() error // CommitWikiToRepo commits any files added or updated since the last commit to our local wiki repo. CommitWikiToRepo(author string, authorEMail string, message string) error // CopyFileToWiki copies an external file into the local clone of the Gitea Wiki CopyFileToWiki(externalFilePath string, giteaWikiRelPath string) error // WriteWikiPage potentially writes a wiki page to the local wiki repository, returning a flag to say whether the file was physically written. // If a previous commit of the wiki page is found containing the provided marker string then the page will only be written if an explicit override has been provided. WriteWikiPage(pageName string, markdownText string, commitMarker string) (bool, error) // TranslateWikiPageName translates a Trac wiki page name into a Gitea one TranslateWikiPageName(pageName string) string }
Accessor is the interface to all of our interactions with a Gitea project.
type DefaultAccessor ¶
type DefaultAccessor struct {
// contains filtered or unexported fields
}
DefaultAccessor is the default implementation of the gitea Accessor interface, accessing Gitea directly via its database and filestore.
func CreateDefaultAccessor ¶
func CreateDefaultAccessor( giteaRootDir string, giteaUserName string, giteaRepoName string, giteaWikiRepoURL string, giteaWikiRepoToken string, giteaWikiRepoDir string, overwriteData bool, pushWiki bool) (*DefaultAccessor, error)
CreateDefaultAccessor returns a new Gitea default accessor.
func (*DefaultAccessor) AddIssue ¶
func (accessor *DefaultAccessor) AddIssue(issue *Issue) (int64, error)
AddIssue adds a new issue to Gitea.
func (*DefaultAccessor) AddIssueAssignee ¶
func (accessor *DefaultAccessor) AddIssueAssignee(issueID int64, assigneeID int64) error
AddIssueAssignee adds an assignee to a Gitea issue
func (*DefaultAccessor) AddIssueAttachment ¶
func (accessor *DefaultAccessor) AddIssueAttachment(issueID int64, attachment *IssueAttachment, filePath string) (int64, error)
AddIssueAttachment adds a new attachment to an issue using the provided file - returns id of created attachment
func (*DefaultAccessor) AddIssueComment ¶
func (accessor *DefaultAccessor) AddIssueComment(issueID int64, comment *IssueComment) (int64, error)
AddIssueComment adds a comment on a Gitea issue, returns id of created comment
func (*DefaultAccessor) AddIssueLabel ¶
func (accessor *DefaultAccessor) AddIssueLabel(issueID int64, labelID int64) (int64, error)
AddIssueLabel adds an issue label to Gitea, returns issue label ID
func (*DefaultAccessor) AddIssueParticipant ¶
func (accessor *DefaultAccessor) AddIssueParticipant(issueID int64, userID int64) error
AddIssueParticipant adds a participant to a Gitea issue.
func (*DefaultAccessor) AddLabel ¶
func (accessor *DefaultAccessor) AddLabel(label *Label) (int64, error)
AddLabel adds a label to Gitea, returns label id.
func (*DefaultAccessor) AddMilestone ¶
func (accessor *DefaultAccessor) AddMilestone(milestone *Milestone) (int64, error)
AddMilestone adds a milestone to Gitea, returns id of created milestone
func (*DefaultAccessor) CloneWiki ¶
func (accessor *DefaultAccessor) CloneWiki() error
CloneWiki clones our wiki repo to the provided directory.
func (*DefaultAccessor) CommitTransaction ¶
func (accessor *DefaultAccessor) CommitTransaction() error
CommitTransaction commits a Gitea transaction.
func (*DefaultAccessor) CommitWikiToRepo ¶
func (accessor *DefaultAccessor) CommitWikiToRepo(author string, authorEMail string, message string) error
CommitWikiToRepo stages any files added or updated since the last commit then commits them to our cloned wiki repo. We package the staging and commit together here because it is easier than embedding hooks to do the git staging deep into the wiki parsing process where files from the Trac worksapce can get copied over on-the-fly.
func (*DefaultAccessor) CopyFileToWiki ¶
func (accessor *DefaultAccessor) CopyFileToWiki(externalFilePath string, giteaWikiRelPath string) error
CopyFileToWiki copies an external file into the Gitea Wiki, returning a URL through which the file can be viewed/
func (*DefaultAccessor) GetCommitURL ¶
func (accessor *DefaultAccessor) GetCommitURL(commitID string) string
GetCommitURL retrieves the URL for viewing a given commit in the current repository
func (*DefaultAccessor) GetIssueAttachmentURL ¶
func (accessor *DefaultAccessor) GetIssueAttachmentURL(issueID int64, uuid string) string
GetIssueAttachmentURL retrieves the URL for viewing a Gitea attachment
func (*DefaultAccessor) GetIssueAttachmentUUID ¶
func (accessor *DefaultAccessor) GetIssueAttachmentUUID(issueID int64, fileName string) (string, error)
GetIssueAttachmentUUID returns the UUID for a named attachment of a given issue - returns empty string if cannot find issue/attachment.
func (*DefaultAccessor) GetIssueCommentIDsByTime ¶
func (accessor *DefaultAccessor) GetIssueCommentIDsByTime(issueID int64, createdTime int64) ([]int64, error)
GetIssueCommentIDsByTime retrieves the IDs of all comments created at a given time for a given issue
func (*DefaultAccessor) GetIssueCommentURL ¶
func (accessor *DefaultAccessor) GetIssueCommentURL(issueID int64, commentID int64) string
GetIssueCommentURL retrieves the URL for viewing a Gitea comment for a given issue.
func (*DefaultAccessor) GetIssueID ¶
func (accessor *DefaultAccessor) GetIssueID(issueIndex int64) (int64, error)
GetIssueID retrieves the id of the Gitea issue corresponding to a given issue index - returns NullID if no such issue.
func (*DefaultAccessor) GetIssueURL ¶
func (accessor *DefaultAccessor) GetIssueURL(issueID int64) string
GetIssueURL retrieves a URL for viewing a given issue
func (*DefaultAccessor) GetLabelID ¶
func (accessor *DefaultAccessor) GetLabelID(labelName string) (int64, error)
GetLabelID retrieves the id of the given label, returns NullID if no such label
func (*DefaultAccessor) GetMilestoneID ¶
func (accessor *DefaultAccessor) GetMilestoneID(milestoneName string) (int64, error)
GetMilestoneID gets the ID of a named milestone - returns NullID if no such milestone
func (*DefaultAccessor) GetMilestoneURL ¶
func (accessor *DefaultAccessor) GetMilestoneURL(milestoneID int64) string
GetMilestoneURL gets the URL for accessing a given milestone
func (*DefaultAccessor) GetSourceURL ¶
func (accessor *DefaultAccessor) GetSourceURL(branchPath string, filePath string) string
GetSourceURL retrieves the URL for viewing the latest version of a source file on a given branch of the current repository
func (*DefaultAccessor) GetStringConfig ¶
func (accessor *DefaultAccessor) GetStringConfig(sectionName string, configName string) string
GetStringConfig retrieves a value from the Gitea config as a string.
func (*DefaultAccessor) GetUserEMailAddress ¶
func (accessor *DefaultAccessor) GetUserEMailAddress(userName string) (string, error)
GetUserEMailAddress retrieves the email address of a given user
func (*DefaultAccessor) GetUserID ¶
func (accessor *DefaultAccessor) GetUserID(userName string) (int64, error)
GetUserID retrieves the id of a named Gitea user - returns NullID if no such user.
func (*DefaultAccessor) GetWikiAttachmentRelPath ¶
func (accessor *DefaultAccessor) GetWikiAttachmentRelPath(pageName string, filename string) string
GetWikiAttachmentRelPath returns the location of an attachment to Trac a wiki page when stored in the Gitea wiki repository. The returned path is relative to the root of the Gitea wiki repository.
func (*DefaultAccessor) GetWikiFileURL ¶
func (accessor *DefaultAccessor) GetWikiFileURL(relpath string) string
GetWikiFileURL returns a URL for viewing a file stored in the Gitea wiki repository.
func (*DefaultAccessor) GetWikiHtdocRelPath ¶
func (accessor *DefaultAccessor) GetWikiHtdocRelPath(filename string) string
GetWikiHtdocRelPath returns the location of a given Trac 'htdocs' file when stored in the Gitea wiki repository. The returned path is relative to the root of the Gitea wiki repository.
func (*DefaultAccessor) MatchUser ¶
func (accessor *DefaultAccessor) MatchUser(userName string, userEmail string) (string, error)
MatchUser retrieves the name of the user best matching a user name or email address
func (*DefaultAccessor) RollbackTransaction ¶
func (accessor *DefaultAccessor) RollbackTransaction() error
RollbackTransaction rolls back a Gitea transaction.
func (*DefaultAccessor) SetIssueUpdateTime ¶
func (accessor *DefaultAccessor) SetIssueUpdateTime(issueID int64, updateTime int64) error
SetIssueUpdateTime sets the update time on a given Gitea issue.
func (*DefaultAccessor) TranslateWikiPageName ¶
func (accessor *DefaultAccessor) TranslateWikiPageName(pageName string) string
TranslateWikiPageName translates a Trac wiki page name into a Gitea one
func (*DefaultAccessor) UpdateIssueCommentCount ¶
func (accessor *DefaultAccessor) UpdateIssueCommentCount(issueID int64) error
UpdateIssueCommentCount updates the count of comments a given issue
func (*DefaultAccessor) UpdateLabelIssueCounts ¶
func (accessor *DefaultAccessor) UpdateLabelIssueCounts() error
UpdateLabelIssueCounts updates issue counts for all labels.
func (*DefaultAccessor) UpdateMilestoneIssueCounts ¶
func (accessor *DefaultAccessor) UpdateMilestoneIssueCounts() error
UpdateMilestoneIssueCounts updates issue counts for all milestones.
func (*DefaultAccessor) UpdateRepoIssueCounts ¶
func (accessor *DefaultAccessor) UpdateRepoIssueCounts() error
UpdateRepoIssueCounts updates issue counts for our chosen Gitea repository.
func (*DefaultAccessor) UpdateRepoMilestoneCounts ¶
func (accessor *DefaultAccessor) UpdateRepoMilestoneCounts() error
UpdateRepoMilestoneCounts updates milestone counts for our chosen Gitea repository.
func (*DefaultAccessor) WriteWikiPage ¶
func (accessor *DefaultAccessor) WriteWikiPage(pageName string, markdownText string, commitMarker string) (bool, error)
WriteWikiPage writes (a version of) a wiki page to the checked-out wiki repository, returning the path to the written file.
type Issue ¶
type Issue struct { Index int64 Summary string ReporterID int64 Milestone string OriginalAuthorID int64 OriginalAuthorName string Closed bool Description string Created int64 Updated int64 }
Issue describes a Gitea issue.
type IssueAttachment ¶
IssueAttachment describes an attachment to a Gitea issue.
type IssueComment ¶
type IssueComment struct { CommentType IssueCommentType AuthorID int64 OriginalAuthorID int64 OriginalAuthorName string LabelID int64 OldMilestoneID int64 MilestoneID int64 AssigneeID int64 RemovedAssigneeID int64 OldTitle string Title string Text string Time int64 }
IssueComment describes a comment on a Gitea issue.
type IssueCommentType ¶
type IssueCommentType int64
IssueCommentType defines the types of issue comment we support
const ( // CommentIssueCommentType is an IssueComment reflecting a comment CommentIssueCommentType IssueCommentType = 0 // ReopenIssueCommentType is an IssueComment reflecting closing an issue ReopenIssueCommentType IssueCommentType = 1 // CloseIssueCommentType is an IssueComment reflecting closing an issue CloseIssueCommentType IssueCommentType = 2 // LabelIssueCommentType is an IssueComment reflecting a label change LabelIssueCommentType IssueCommentType = 7 // MilestoneIssueCommentType is an IssueComment reflecting a milestone change MilestoneIssueCommentType IssueCommentType = 8 // AssigneeIssueCommentType is an IssueComment reflecting an assignee change AssigneeIssueCommentType IssueCommentType = 9 // TitleIssueCommentType is an IssueComment reflecting a title change TitleIssueCommentType IssueCommentType = 10 )