utils

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package utils is intended to provide some useful functions

Package utils is intended to provide some useful functions

Package utils is intended to provide some useful functions

Package utils is intended to provide some useful functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitRepository

func CommitRepository() error

CommitRepository will commit all local changes

func GetBundleVersion

func GetBundleVersion() (string, error)

GetBundleVersion Get bundle version by reading version lockfile

func GetGitAuth

func GetGitAuth() (transport.AuthMethod, error)

GetGitAuth will return transport.AuthMethod interface by driver that configure in config file

func GetMillionSecondTimestamp

func GetMillionSecondTimestamp() int64

GetMillionSecondTimestamp will return current timestamp (ms)

func Push

func Push() error

Push will push local changes(includes tags) to remote repository

func ReleaseRepository

func ReleaseRepository() error

ReleaseRepository will create a git tag

func SyncRepository

func SyncRepository() error

SyncRepository will force sync local repository correspond to remote repository

Types

type CategoryUnit

type CategoryUnit struct {
	database.Category
	Path string `json:"path"`
}

CategoryUnit is unit of category collection, stored in categories.json file

type CategoryUnitCollection

type CategoryUnitCollection []CategoryUnit

CategoryUnitCollection is collection of category unit

func DeepCopyCategoryUnitCollection

func DeepCopyCategoryUnitCollection(collection CategoryUnitCollection) CategoryUnitCollection

DeepCopyCategoryUnitCollection deep copy from source

func (*CategoryUnitCollection) ImportFrom

func (p *CategoryUnitCollection) ImportFrom(c []database.Category)

ImportFrom can convert []category to []categoryUnit

type SentencesUnit

type SentencesUnit struct {
	Name      string `json:"name"`
	Key       string `json:"key"`
	Path      string `json:"path"`
	Timestamp int64  `json:"timestamp"`
}

SentencesUnit is a unit of VersionData SentencesUnitCollection

type SentencesUnitCollection

type SentencesUnitCollection []SentencesUnit

SentencesUnitCollection is a collection of SentencesUnit

func DeepCopySentencesUnitCollection

func DeepCopySentencesUnitCollection(s SentencesUnitCollection) SentencesUnitCollection

DeepCopySentencesUnitCollection deep copy from source

func (*SentencesUnitCollection) Find

Find will return specific SentencesUnit Pointer

func (*SentencesUnitCollection) Update

func (c *SentencesUnitCollection) Update(key string) error

Update will update the timestamp of specific SentencesUnit

type VersionData

type VersionData struct {
	ProtocolVersion string `json:"protocol_version"`
	BundleVersion   string `json:"bundle_version"`
	UpdatedAt       int64  `json:"updated_at"`
	Categories      struct {
		Path      string `json:"path"`
		Timestamp int64  `json:"timestamp"`
	} `json:"categories"`
	Sentences SentencesUnitCollection `json:"sentences"`
}

VersionData is the structure of version lockfile

func DeepCopyVersionData

func DeepCopyVersionData(data VersionData) VersionData

DeepCopyVersionData deep copy from source

func (*VersionData) StepVersion

func (v *VersionData) StepVersion() error

StepVersion will increase patch version

func (*VersionData) UpdateCategoriesRecord

func (v *VersionData) UpdateCategoriesRecord(categoriesData CategoryUnitCollection)

UpdateCategoriesRecord will update timestamp in categories field and updated_at field

func (*VersionData) UpdateSentenceRecord

func (v *VersionData) UpdateSentenceRecord(categoryKey string) error

UpdateSentenceRecord will update timestamp in specific category of sentences field and updated_at field

Jump to

Keyboard shortcuts

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