ticket

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Ticket implements routines for working with Giticket Tickets

The ticket package uses the git2go library to work with git repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddComment

func AddComment(t *Ticket, comment string, thisRepo *git.Repository, branchName string, debug bool) (string, error)

AddComment adds a comment to ticket t under the repo and branchName provided with a debug flag. It returns a string representing the unique ID of the added comment and an error if there is was one.

func AddLabel

func AddLabel(t *Ticket, label string, repo *git.Repository, branchName string, debug bool) string

AddLabel() takes a pointer to a ticket, a label, a git repo, a branch name, and a debug flag. It adds the label to the ticket and returns an error.

func DeleteComment

func DeleteComment(t *Ticket, commentID int, repo *git.Repository, branchName string, debug bool) string

DeleteComment removes the comment identified by commentID from ticket t under the repo and branchName provided with a debug flag. It returns a string representing the unique ID of the deleted comment.

func DeleteLabel

func DeleteLabel(t *Ticket, label string, repo *git.Repository, branchName string, debug bool) string

DeleteLabel() takes a pointer to a ticket, a label, a git repo, a branch name, and a debug flag. It deletes the label from the ticket and returns an error.

func FilterTickets added in v0.3.2

func FilterTickets(tickets []Ticket, filterName string, debugFlag bool) (*[]Ticket, error)

FilterTickets takes a list of tickets, a filter name, and a debug flag. It returns a list of tickets that match the filter. Returns an error if there is one.

func GetCurrentFilter added in v0.3.2

func GetCurrentFilter(debugFlag bool) (string, error)

GetCurrentFilter takes a debug flag and returns the name of the current filter. Returns an error if there is one. This function may return an empty string if the current filter has not yet been set.

func HandleComment

func HandleComment(
	branchName string,
	comment string,
	commentID int,
	ticketID int,
	deleteFlag bool,
	debugFlag bool,
) (string, error)

HandleComment handles the addition or deletion of a comment for a ticket. It takes in the branch name, comment content, comment ID, ticket ID, delete flag, and debug flag as parameters. If the delete flag is true, it deletes the specified comment from the ticket. Otherwise, it adds the comment to the ticket. The function returns the comment ID and an error if there is one.

func HandleCreate

func HandleCreate(
	branchName string,
	created int64,
	title string,
	description string,
	labels []string,
	priority int,
	severity int,
	status string,
	comments []Comment,
	nextCommentId int,
	debugFlag bool,
) (int, string, error)

func HandleDelete

func HandleDelete(ticketID int, branchName string, debugFlag bool) (bool, error)

Delete the comment from the tree for the ticket with the given ID

func HandleFilterCreate added in v0.3.2

func HandleFilterCreate(filter string, filterName string, debugFlag bool) error

HandleFilterCreate takes a filter string, a filter name, and a debug flag and creates a filter. It returns an error if there is one.

func HandleFilterDelete added in v0.3.2

func HandleFilterDelete(filterName string, debugFlag bool) error

HandleFilterDelete takes the name of a filter and a debug flag, and deletes the filter. It returns an error if there is one.

func HandleFilterList added in v0.3.2

func HandleFilterList(writer io.Writer, outputFormat string, debugFlag bool) error

HandleFilterList takes a debug flag and lists all filters. It returns an error if there is one.

func HandleLabel

func HandleLabel(
	branchName string,
	label string,
	deleteFlag bool,
	ticketID int,
	debugFlag bool,
) error

HandleLabel handles adding or deleting a label from a ticket based on the value of deleteFlag, returning an error if there was one.

func HandleList

func HandleList(w io.Writer, windowWidth int, branchName string, filterName string, filterSet bool, debugFlag bool) error

func HandlePriority

func HandlePriority(ticketID int, priority int, debugFlag bool) error

HandlePriority sets the priority of a giticket ticket

func HandleSeverity

func HandleSeverity(ticketID int, severity int, debugFlag bool) error

HandleSeverity sets the severity of a giticket ticket

func HandleShow

func HandleShow(ticketID int, output string, debugFlag bool, helpFlag bool) error

HandleShow is used to print a list of giticket tickets in a number of formats

func HandleStatus

func HandleStatus(
	status string,
	ticketID int,
	helpFlag bool,
	debugFlag bool,
) error

func ListTickets

func ListTickets(thisRepo *git.Repository, branchName string, windowWidth int, filterName string, filterSet bool, debugFlag bool) (string, error)

func PrintParameterMissing

func PrintParameterMissing(param string)

func ReadNextTicketID

func ReadNextTicketID(repo *git.Repository, commit *git.Commit) (int, error)

Return the value of ".giticket/next_ticket_id" from the given commit as an int, or returns 0 and an error. Make sure to write the incremented value back things to ".giticket/next_ticket_id" in the same commit. Repo is required to lookup treeIDs

func ShowTicket

func ShowTicket(ticket Ticket, output string, debug bool)

ShowTicket takes a ticket, an output type, and a debug flag and prints the ticket details in the given format.

func ShowTicketsJson

func ShowTicketsJson(t Ticket, debug bool)

ShowTicketsJson is used to print a list of giticket tickets in json format

func ShowTicketsText

func ShowTicketsText(t Ticket, debug bool)

ShowTicketsText is used to print a list of giticket tickets in text format

func ShowTicketsYaml

func ShowTicketsYaml(t Ticket, debug bool)

ShowTicketsYaml is used to print a list of giticket tickets in yaml format

func TestHandleLabel

func TestHandleLabel(t *testing.T)

func WriteFilters added in v0.3.2

func WriteFilters(filters *FilterList, commitMessage string, branchName string, debugFlag bool) error

Types

type Comment

type Comment struct {
	ID      int
	Created int64
	Body    string
	Author  string
}

A comment for a giticket ticket The fields must be filled in to populate details of the ticket

type Filter added in v0.3.2

type Filter struct {
	Name   string
	Filter string

	CreatedAt string
}

Filter is used in ticket list operations to return a subset of tickets

func GetFilter added in v0.3.2

func GetFilter(filterName string, debugFlag bool) (Filter, error)

GetFilter takes a filter name and a debug flag, and returns that filter and an error if one was encountered. Returns error if named filter was not found.

type FilterList added in v0.3.2

type FilterList struct {
	CurrentFilter string
	Filters       map[string]Filter
}

FilterList is a list of Filters and a value that represents the 'current' filter to use

func GetFilters added in v0.3.2

func GetFilters(branchName string, debugFlag bool) (*FilterList, error)

type Ticket

type Ticket struct {
	Title         string
	Description   string
	Labels        []string
	Priority      int
	Severity      int
	Status        string
	Comments      []Comment
	NextCommentID int `yaml:"next_comment_id" json:"next_comment_id"`

	// Set automatically
	ID      int
	Created int64
}

func FilterTicketsByID

func FilterTicketsByID(tickets []Ticket, id int) Ticket

FilterTicketsByID takes a list of tickets and an integer representing the ticket ID to filter for, and return that ticket.

func GetListOfTickets

func GetListOfTickets(thisRepo *git.Repository, branchName string, debugFlag bool) ([]Ticket, error)

func GetTicketsList

func GetTicketsList() ([]Ticket, error)

GetTicketsList takes no parameters and returns a list of tickets It is intended to be used by giticket-webui, GetListOfTickets requires a repo parameter, this creates the repo and calls GetListOfTickets

func (*Ticket) TicketFilename

func (t *Ticket) TicketFilename() string

TicketFilename() returns the filename of the ticket by cating the ticket ID and the ticket title, with spaces replaced by underscores

func (*Ticket) TicketToYaml

func (t *Ticket) TicketToYaml() []byte

TicketToYaml() returns the ticket as a YAML string which is used to save to disk

Jump to

Keyboard shortcuts

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