Documentation ¶
Overview ¶
Package types defines the data structures and regular expressions that helps to unmarshal commits history string into data to be shared with the outside world.
Index ¶
- Constants
- Variables
- func ClearProposalToken()
- func CustomUnmashaller(h *History, str string, since ...time.Time) error
- func GetProposalToken() string
- func IsGitVersionSupported(parsedStr string) error
- func IsMatching(parent, matchRegex string) bool
- func ReplaceAny(parent, regex, with string) string
- func ReplaceJournalSelection(parent, with string) string
- func RetrieveAllPatchSelection(parent string) string
- func RetrieveCMDAuthor(parent string) (string, error)
- func RetrieveCMDCommit(parent string) (string, error)
- func RetrieveCMDDate(parent string) (time.Time, error)
- func RetrieveProposalToken(parent string) (string, error)
- func SetProposalToken(token string) error
- func SplitCommitDiff(parent string) []string
- func ToBitcast(in string) bitCast
- func VotesJSONSignature() string
- type CastVoteData
- type File
- type History
- type PiRegExp
- type PiVote
- type Votes
Constants ¶
const ( // DefaultRepo is the default github repository name where Politea Votes // are stored. DefaultRepo = "mainnet" // DefaultRepoOwner is the owner of the default github repository where // Politeia votes are stored. DefaultRepoOwner = "decred-proposals" // DefaultVotesCommitMsg defines the message of the commits that holds // the votes data for the various proposal token(s). DefaultVotesCommitMsg = "Flush vote journals" // CmdDateFormat defines the date format of the time returned by git commandline // interface. Time format is known as RFC2822. CmdDateFormat = "Mon Jan 2 15:04:05 2006 -0700" )
Variables ¶
var ErrGitVersion = errors.New("invalid git version found. A minimum of v" +
minGitVersion.String() + " was expected")
ErrGitVersion is the default error returned if an invalid git version was found.
Functions ¶
func ClearProposalToken ¶
func ClearProposalToken()
ClearProposalToken deletes the current proposal token value.
func CustomUnmashaller ¶
CustomUnmashaller unmarshals the string argument passed. Its not in a JSON format. History unmarshalling happens ONLY for the set proposal token and for all proposal tokens available if otherwise (not set).
func GetProposalToken ¶
func GetProposalToken() string
GetProposalToken returns the current proposal token value set.
func IsGitVersionSupported ¶
IsGitVersionSupported checks if the git version in the parse string is supported. An error is returned if otherwise.
func IsMatching ¶
IsMatching returns boolean true if the matchRegex can be matched in the parent string.
func ReplaceAny ¶
ReplaceAny replaces the all occurence of "regex" in string "parent" with replacement "with" for all the possible occurences.
func ReplaceJournalSelection ¶
ReplaceJournalSelection uses journalSelection regex expression to replace the journal action in the provided parent string using the provided replacement.
func RetrieveAllPatchSelection ¶
RetrieveAllPatchSelection uses patchSelection regex expression to fetch all individual matching lines from the provided parent string.
func RetrieveCMDAuthor ¶
RetrieveCMDAuthor uses cmdAuthorSelection regex expression to retrieve the Author value in the provided parent string.
func RetrieveCMDCommit ¶
RetrieveCMDCommit uses cmdCommitSelection to retrieve the commit SHA value from the provided parent string.
func RetrieveCMDDate ¶
RetrieveCMDDate uses cmdDateSelection regex expression to retrieve the Date value in the provided parent string. The fetched date string is converted into a time.Time objected using "Mon Jan 2 15:04:05 2006 -0700" date format.
func RetrieveProposalToken ¶
RetrieveProposalToken uses the anyTokenSelection regex to build a regex expression used to select the proposal token from the parent string.
func SetProposalToken ¶
SetProposalToken sets the current proposal token string whose data is being unmarshalled.
func SplitCommitDiff ¶
SplitCommitDiff uses the commitDiff separating string to split the string into an array.
func VotesJSONSignature ¶
func VotesJSONSignature() string
VotesJSONSignature defines a part of the json string signature that matches the commit patch string required. The matched commit patch string contains the needed votes data.
Types ¶
type CastVoteData ¶
type CastVoteData struct {
*PiVote `json:"castvote"`
}
CastVoteData defines the struct of a cast vote and the reciept response.
type File ¶
File defines the votes cast for a single token in a commit. A commit can votes cast for several commits joined together.
type History ¶
History defines the standard single commit history contents to be shared with the outside world.
type PiRegExp ¶
type PiRegExp string
PiRegExp helps defines the various regex expression supported. It also helps to easily compile them.
type PiVote ¶
type PiVote struct { // Token string `json:"token"` Ticket string `json:"ticket"` VoteBit bitCast `json:"votebit"` }
PiVote defines the ticket hash and vote bit type details about a vote.
type Votes ¶
type Votes []CastVoteData
Votes defines a slice type of votes cast data.
func (*Votes) UnmarshalJSON ¶
UnmarshalJSON defines the default unmarshaller for Votes.