trac

package
v0.0.0-...-fab09df Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

README

trac2gitea accessor.gitea Package

This provides low-level access to Trac data.

All Trac database accesses are encapsulated here so any changes for different DB types and SQL dialects should be limited to this package.

Documentation

Index

Constants

View Source
const (
	// TicketStatusClosed indicates a closed Trac ticket
	TicketStatusClosed string = "closed"

	// TicketStatusReopened indicates a reopened Trac ticket
	TicketStatusReopened string = "reopened"
)
View Source
const NullID = int64(-1)

NullID id used for Trac lookup failures The Trac schema does not seem to use foreign key references so there is no specific null Trac id value The value chosen here is therefore just one that will not occur in reality and is also simultaneously different from the Gitea one so we are more likely to detect mis-assignments.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessor

type Accessor interface {
	/*
	 * Components
	 */
	// GetComponents retrieves all Trac components, passing each one to the provided "handler" function.
	GetComponents(handlerFn func(component *Label) error) error

	/*
	 * Configuration
	 */
	// GetStringConfig retrieves a value from the Trac config as a string.
	GetStringConfig(sectionName string, configName string) string

	/*
	 * Milestones
	 */
	// GetMilestones retrieves all Trac milestones, passing data from each one to the provided "handler" function.
	GetMilestones(handlerFn func(milestone *Milestone) error) error

	/*
	 * Paths
	 */
	// GetFullPath retrieves the absolute path of a path relative to the root of the Trac installation.
	GetFullPath(element ...string) string

	/*
	 * Priorities
	 */
	// GetPriorities retrieves all priorities used in Trac tickets, passing each one to the provided "handler" function.
	GetPriorities(handlerFn func(priority *Label) error) error

	/*
	 * Resolutions
	 */
	// GetResolutions retrieves all resolutions used in Trac tickets, passing each one to the provided "handler" function.
	GetResolutions(handlerFn func(resolution *Label) error) error

	/*
	 * Severities
	 */
	// GetSeverities retrieves all severities used in Trac tickets, passing each one to the provided "handler" function.
	GetSeverities(handlerFn func(severity *Label) error) error

	/*
	 * Tickets
	 */
	// GetTickets retrieves all Trac tickets, passing data from each one to the provided "handler" function.
	GetTickets(handlerFn func(ticket *Ticket) error) error

	/*
	 * Ticket Changes
	 */
	// GetTicketChanges retrieves all changes on a given Trac ticket in ascending time order, passing data from each one to the provided "handler" function.
	GetTicketChanges(ticketID int64, handlerFn func(change *TicketChange) error) error

	// GetTicketCommentTime retrieves the timestamp for a given comment for a given Trac ticket
	GetTicketCommentTime(ticketID int64, changeNum int64) (int64, error)

	/*
	 * Ticket Attachments
	 */
	// GetTicketAttachmentPath retrieves the path to a named attachment to a Trac ticket.
	GetTicketAttachmentPath(attachment *TicketAttachment) string

	// GetTicketAttachments retrieves all attachments for a given Trac ticket, passing data from each one to the provided "handler" function.
	GetTicketAttachments(ticketID int64, handlerFn func(attachment *TicketAttachment) error) error

	/*
	 * Types
	 */
	// GetTypes retrieves all types used in Trac tickets, passing each one to the provided "handler" function.
	GetTypes(handlerFn func(tracType *Label) error) error

	/*
	 * Users
	 */
	// GetUserNames retrieves the names of all users mentioned in Trac tickets, wiki pages etc., passing each one to the provided "handler" function.
	GetUserNames(handlerFn func(userName string) error) error

	/*
	 * Versions
	 */
	// GetVersions retrieves all versions used in Trac, passing each one to the provided "handler" function.
	GetVersions(handlerFn func(version *Label) error) error

	/*
	 * Wiki
	 */
	// GetWikiPages retrieves all Trac wiki pages, passing data from each one to the provided "handler" function.
	GetWikiPages(handlerFn func(page *WikiPage) error) error

	// GetWikiAttachmentPath retrieves the path to a named attachment to a Trac wiki page.
	GetWikiAttachmentPath(attachment *WikiAttachment) string

	// GetWikiAttachments retrieves all Trac wiki page attachments, passing data from each one to the provided "handler" function.
	GetWikiAttachments(handlerFn func(attachment *WikiAttachment) error) error

	// IsPredefinedPage returns true if the provided page name is one of Trac's predefined ones - by default we ignore these
	IsPredefinedPage(pageName string) bool
}

Accessor is the interface through which we access all Trac data.

type DefaultAccessor

type DefaultAccessor struct {
	// contains filtered or unexported fields
}

DefaultAccessor is the default implementation of the trac Accessor interface, accessing Trac via its database and filestore.

func CreateDefaultAccessor

func CreateDefaultAccessor(tracRootDir string) (*DefaultAccessor, error)

CreateDefaultAccessor creates a new Trac accessor.

func (*DefaultAccessor) GetComponents

func (accessor *DefaultAccessor) GetComponents(handlerFn func(component *Label) error) error

GetComponents retrieves all Trac components, passing each one to the provided "handler" function.

func (*DefaultAccessor) GetFullPath

func (accessor *DefaultAccessor) GetFullPath(element ...string) string

GetFullPath retrieves the absolute path of a path relative to the root of the Trac installation.

func (*DefaultAccessor) GetMilestones

func (accessor *DefaultAccessor) GetMilestones(handlerFn func(milestone *Milestone) error) error

GetMilestones retrieves all Trac milestones, passing data from each one to the provided "handler" function.

func (*DefaultAccessor) GetPriorities

func (accessor *DefaultAccessor) GetPriorities(handlerFn func(priority *Label) error) error

GetPriorities retrieves all priorities used in Trac tickets, passing each one to the provided "handler" function.

func (*DefaultAccessor) GetResolutions

func (accessor *DefaultAccessor) GetResolutions(handlerFn func(resolution *Label) error) error

GetResolutions retrieves all resolutions used in Trac tickets, passing each one to the provided "handler" function.

func (*DefaultAccessor) GetSeverities

func (accessor *DefaultAccessor) GetSeverities(handlerFn func(severity *Label) error) error

GetSeverities retrieves all severities used in Trac tickets, passing each one to the provided "handler" function.

func (*DefaultAccessor) GetStringConfig

func (accessor *DefaultAccessor) GetStringConfig(sectionName string, configName string) string

GetStringConfig retrieves a value from the Trac config as a string.

func (*DefaultAccessor) GetTicketAttachmentPath

func (accessor *DefaultAccessor) GetTicketAttachmentPath(attachment *TicketAttachment) string

GetTicketAttachmentPath retrieves the path to a named attachment to a Trac ticket.

func (*DefaultAccessor) GetTicketAttachments

func (accessor *DefaultAccessor) GetTicketAttachments(ticketID int64, handlerFn func(attachment *TicketAttachment) error) error

GetTicketAttachments retrieves all attachments for a given Trac ticket, passing data from each one to the provided "handler" function.

func (*DefaultAccessor) GetTicketChanges

func (accessor *DefaultAccessor) GetTicketChanges(ticketID int64, handlerFn func(change *TicketChange) error) error

GetTicketChanges retrieves all changes on a given Trac ticket in ascending time order, passing data from each one to the provided "handler" function.

func (*DefaultAccessor) GetTicketCommentTime

func (accessor *DefaultAccessor) GetTicketCommentTime(ticketID int64, commentNum int64) (int64, error)

GetTicketCommentTime retrieves the timestamp for a given comment for a given Trac ticket

func (*DefaultAccessor) GetTickets

func (accessor *DefaultAccessor) GetTickets(handlerFn func(ticket *Ticket) error) error

GetTickets retrieves all Trac tickets, passing data from each one to the provided "handler" function.

func (*DefaultAccessor) GetTypes

func (accessor *DefaultAccessor) GetTypes(handlerFn func(tracType *Label) error) error

GetTypes retrieves all types used in Trac tickets, passing each one to the provided "handler" function.

func (*DefaultAccessor) GetUserNames

func (accessor *DefaultAccessor) GetUserNames(handlerFn func(userName string) error) error

GetUserNames retrieves the names of all users mentioned in Trac tickets, wiki pages etc., passing each one to the provided "handler" function.

func (*DefaultAccessor) GetVersions

func (accessor *DefaultAccessor) GetVersions(handlerFn func(version *Label) error) error

GetVersions retrieves all versions used in Trac, passing each one to the provided "handler" function.

func (*DefaultAccessor) GetWikiAttachmentPath

func (accessor *DefaultAccessor) GetWikiAttachmentPath(attachment *WikiAttachment) string

GetWikiAttachmentPath retrieves the path to a named attachment to a Trac wiki page.

func (*DefaultAccessor) GetWikiAttachments

func (accessor *DefaultAccessor) GetWikiAttachments(handlerFn func(attachment *WikiAttachment) error) error

GetWikiAttachments retrieves all Trac wiki page attachments, passing data from each one to the provided "handler" function.

func (*DefaultAccessor) GetWikiPages

func (accessor *DefaultAccessor) GetWikiPages(handlerFn func(page *WikiPage) error) error

GetWikiPages retrieves all Trac wiki pages, passing data from each one to the provided "handler" function.

func (*DefaultAccessor) IsPredefinedPage

func (accessor *DefaultAccessor) IsPredefinedPage(pageName string) bool

IsPredefinedPage returns true if the provided page name is one of Trac's predefined ones - by default we ignore these

type Label

type Label struct {
	Name        string
	Description string
}

Label describes a Trac "label" - a generalisation of a component, priority, resolution, severity, type and version

type Milestone

type Milestone struct {
	Name        string
	Description string
	Due         int64
	Completed   int64
}

Milestone describes a Trac milestone.

type Ticket

type Ticket struct {
	TicketID       int64
	Summary        string
	Description    string
	Owner          string
	Reporter       string
	MilestoneName  string
	ComponentName  string
	PriorityName   string
	ResolutionName string
	SeverityName   string
	TypeName       string
	VersionName    string
	Status         string
	Created        int64
	Updated        int64
}

Ticket describes a Trac milestone.

type TicketAttachment

type TicketAttachment struct {
	TicketID    int64
	Time        int64
	Size        int64
	Author      string
	FileName    string
	Description string
}

TicketAttachment describes an attachment to a Trac ticket.

type TicketChange

type TicketChange struct {
	TicketID   int64
	ChangeType TicketChangeType
	Author     string
	OldValue   string
	NewValue   string
	Time       int64
}

TicketChange describes a change to a Trac ticket.

type TicketChangeType

type TicketChangeType string

TicketChangeType enumerates the types of ticket change we handle.

const (
	// TicketCommentChange denotes a ticket comment change.
	TicketCommentChange TicketChangeType = "comment"

	// TicketComponentChange denotes a ticket component change.
	TicketComponentChange TicketChangeType = "component"

	// TicketMilestoneChange denotes a ticket milestone change.
	TicketMilestoneChange TicketChangeType = "milestone"

	// TicketOwnerChange denotes a ticket ownership change.
	TicketOwnerChange TicketChangeType = "owner"

	// TicketPriorityChange denotes a ticket resolution change.
	TicketPriorityChange TicketChangeType = "priority"

	// TicketResolutionChange denotes a ticket resolution change.
	TicketResolutionChange TicketChangeType = "resolution"

	// TicketSeverityChange denotes a ticket severity change.
	TicketSeverityChange TicketChangeType = "severity"

	// TicketStatusChange denotes a ticket status change.
	TicketStatusChange TicketChangeType = "status"

	// TicketSummaryChange denotes a ticket summary change.
	TicketSummaryChange TicketChangeType = "summary"

	// TicketTypeChange denotes a ticket type change.
	TicketTypeChange TicketChangeType = "type"

	// TicketVersionChange denotes a ticket type change.
	TicketVersionChange TicketChangeType = "version"
)

type WikiAttachment

type WikiAttachment struct {
	PageName string
	FileName string
}

WikiAttachment describes an attachment to a Trac wiki page.

type WikiPage

type WikiPage struct {
	Name       string
	Text       string
	Author     string
	Comment    string
	Version    int64
	UpdateTime int64
}

WikiPage describes a Trac wiki page.

Jump to

Keyboard shortcuts

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