smithy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

This file is largely based on https://github.com/go-git/go-git/blob/70111361e674d786d3e8fca494229d0ad8361de9/plumbing/format/diff/unified_encoder.go Original code licensed under Apache 2.0

Index

Constants

View Source
const DefaultContextLines = 3

DefaultContextLines is the default number of context lines.

View Source
const PAGE_SIZE int = 100

Variables

This section is empty.

Functions

func AddConfigMiddleware

func AddConfigMiddleware(cfg SmithyConfig) gin.HandlerFunc

Make the config available to every request

func CommitView

func CommitView(ctx *gin.Context, urlParts []string)

func DefaultParam

func DefaultParam(ctx *gin.Context, key, def string) string

func Dispatch

func Dispatch(ctx *gin.Context, routes []Route, fileSystemHandler http.Handler)

func FormatChanges

func FormatChanges(changes object.Changes) (string, error)

FormatChanges spits out something similar to `git diff`

func FormatMarkdown

func FormatMarkdown(input string) string

func GenerateDefaultConfig

func GenerateDefaultConfig()

func GetChanges

func GetChanges(commit *object.Commit) (object.Changes, error)

func GetReadmeFromCommit

func GetReadmeFromCommit(commit *object.Commit) (*object.File, error)

func Http404

func Http404(ctx *gin.Context)

func Http500

func Http500(ctx *gin.Context)

func IndexView

func IndexView(ctx *gin.Context, urlParts []string)

func InitFileSystemHandler

func InitFileSystemHandler(smithyConfig SmithyConfig) http.Handler

func ListBranches

func ListBranches(r *git.Repository) ([]*plumbing.Reference, error)

func ListTags

func ListTags(r *git.Repository) ([]*plumbing.Reference, error)

func LogView

func LogView(ctx *gin.Context, urlParts []string)

func LogViewDefault

func LogViewDefault(ctx *gin.Context, urlParts []string)

func PatchHTML

func PatchHTML(p object.Patch) string

PatchHTML returns an HTML representation of a patch

func PatchView added in v0.3.0

func PatchView(ctx *gin.Context, urlParts []string)

func PathExists

func PathExists(path string) (bool, error)

func ReferenceCollector

func ReferenceCollector(it storer.ReferenceIter) ([]*plumbing.Reference, error)

func RefsView

func RefsView(ctx *gin.Context, urlParts []string)

func RenderSyntaxHighlighting

func RenderSyntaxHighlighting(file *object.File) (string, error)

func RepoGitView added in v0.2.0

func RepoGitView(ctx *gin.Context, urlParts []string)

func RepoIndexView

func RepoIndexView(ctx *gin.Context, urlParts []string)

func StartServer

func StartServer(cfgFilePath string, debug bool)

func TreeView

func TreeView(ctx *gin.Context, urlParts []string)

Types

type Commit

type Commit struct {
	Commit    *object.Commit
	Subject   string
	ShortHash string
}

func (*Commit) FormattedDate

func (c *Commit) FormattedDate() string

type GitConfig

type GitConfig struct {
	Root  string       `yaml:"root"`
	Repos []RepoConfig `yaml:",omitempty"`
	// contains filtered or unexported fields
}

type ReferenceByName

type ReferenceByName []*plumbing.Reference

func (ReferenceByName) Len

func (r ReferenceByName) Len() int

func (ReferenceByName) Less

func (r ReferenceByName) Less(i, j int) bool

func (ReferenceByName) Swap

func (r ReferenceByName) Swap(i, j int)

type RepoConfig

type RepoConfig struct {
	Path        string
	Slug        string
	Title       string
	Description string
	Exclude     bool
}

type RepositoryByName

type RepositoryByName []RepositoryWithName

func (RepositoryByName) Len

func (r RepositoryByName) Len() int

func (RepositoryByName) Less

func (r RepositoryByName) Less(i, j int) bool

func (RepositoryByName) Swap

func (r RepositoryByName) Swap(i, j int)

type RepositoryWithName

type RepositoryWithName struct {
	Name       string
	Repository *git.Repository
	Meta       RepoConfig
}

type Route

type Route struct {
	Pattern *regexp.Regexp
	View    func(*gin.Context, []string)
}

func CompileRoutes

func CompileRoutes() []Route

type SmithyConfig

type SmithyConfig struct {
	Title       string `yaml:"title"`
	Description string `yaml:"description"`
	Host        string `yaml:"host"`
	Git         GitConfig
	Static      StaticConfig
	Templates   struct {
		Dir string
	}
	Port int `yaml:"port"`
}

func LoadConfig

func LoadConfig(path string) (SmithyConfig, error)

func New

func New() SmithyConfig

func (*SmithyConfig) FindRepo

func (sc *SmithyConfig) FindRepo(slug string) (RepositoryWithName, bool)

func (*SmithyConfig) GetRepositories

func (sc *SmithyConfig) GetRepositories() []RepositoryWithName

func (*SmithyConfig) LoadAllRepositories

func (sc *SmithyConfig) LoadAllRepositories() error

type StaticConfig added in v0.2.0

type StaticConfig struct {
	Root   string
	Prefix string
}

type TreeEntry

type TreeEntry struct {
	Name string
	Mode filemode.FileMode
	Hash plumbing.Hash
}

func ConvertTreeEntries

func ConvertTreeEntries(entries []object.TreeEntry) []TreeEntry

func (*TreeEntry) FileMode

func (te *TreeEntry) FileMode() string

type UnifiedEncoder

type UnifiedEncoder struct {
	io.Writer
	// contains filtered or unexported fields
}

UnifiedEncoder encodes an unified diff into the provided Writer. It does not support similarity index for renames or sorting hash representations.

func NewUnifiedEncoder

func NewUnifiedEncoder(w io.Writer, contextLines int) *UnifiedEncoder

NewUnifiedEncoder returns a new UnifiedEncoder that writes to w.

func (*UnifiedEncoder) Encode

func (e *UnifiedEncoder) Encode(patch object.Patch) error

Encode encodes patch.

Jump to

Keyboard shortcuts

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