common

package
v0.0.0-...-81b3271 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package common contains functionality not critical to the core project but still essential.

Package common contains functionality not critical to the core project but still essential.

Package common contains functionality not critical to the core project but still essential.

Package common contains functionality not critical to the core project but still essential.

Package common contains functionality not critical to the core project but still essential.

Package common contains functionality not critical to the core project but still essential.

Package common contains functionality not critical to the core project but still essential.

Index

Constants

View Source
const (
	Name        = "gitrob"
	ASCIIBanner = "        _ __           __\n" +
		"  ___ _(_) /________  / /\n" +
		" / _ `/ / __/ __/ _ \\/ _ \\\n" +
		" \\_, /_/\\__/_/  \\___/_.__/\n" +
		"/___/"
)

Project name and banner

View Source
const (
	FATAL     = 5
	ERROR     = 4
	WARN      = 3
	IMPORTANT = 2
	INFO      = 1
	DEBUG     = 0
)

These are a consistent set of error codes instead of using random non-zero integers

View Source
const (
	TargetTypeUser         = "User"
	TargetTypeOrganization = "Organization"
)

Set easier names to refer to

View Source
const (
	EmptyTreeCommitId = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
)

EmptyTreeCommit is a dummy commit id used as a placeholder and for testing

View Source
const GitLabTanuki = "\n" +
	"      //               //     \n" +
	"     ////             ////    \n" +
	"    //////           //////   \n" +
	"   ((((((((/////////((((((((  \n" +
	"   ((((((((////////(((((((((  \n" +
	"  ((((((((((///////(((((((((( \n" +
	"     ((((((((/////((((((((    \n" +
	"         (((((///(((((        \n" +
	"            (((/(((           \n" +
	"               *              \n" +
	"        GitLab Red Team       \n" +
	"\n"

GitLabTanuki is the Gitlab specific banner

Variables

LogColors sets the color for each type of logging output

View Source
var UserAgent = fmt.Sprintf("%s v%s", Name, Version)

UserAgent set the browser user agent when required.

View Source
var Version = version.AppVersion()

Version is the current version of gitlab

Functions

func AppendIfMissing

func AppendIfMissing(slice []string, s string) []string

AppendIfMissing will check a slice for a value before appending it

func CleanUrlSpaces

func CleanUrlSpaces(dirtyStrings ...string) []string

CleanUrlSpaces will take a string and replace any spaces with dashes so that is may be used in a url.

func FileExists

func FileExists(path string) bool

FileExists will check for the existence of a file and return a bool depending on if it exists in a given path or not.

func GetChangeAction

func GetChangeAction(change *object.Change) string

func GetChangeContent

func GetChangeContent(change *object.Change) (result string, contentError error)

GetChangeContent will get the contents of a git change or patch.

func GetChangePath

func GetChangePath(change *object.Change) string

GetChangeAction will set the action of the commit to something that is more easily readable.

func GetChanges

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

GetChanges will get the changes between to specific commits

func GetRepositoryHistory

func GetRepositoryHistory(repository *git.Repository) ([]*object.Commit, error)

GetRepositoryHistory gets the commit history of a repository

func PathExists

func PathExists(path string) bool

pathExists will check if a path exists or not and is used to validate user input

func Pluralize

func Pluralize(count int, singular string, plural string) string

Pluralize will take in a count and if the count is != 1 it will return the singular of the word.

func SetHomeDir

func SetHomeDir(h string) string

SetHomeDir will set the correct homedir.

func TruncateString

func TruncateString(str string, maxLength int) string

TruncateString will take an integer and cut a string at that length and append an ellipsis to it.

Types

type CloneConfiguration

type CloneConfiguration struct {
	InMemClone *bool
	Url        *string
	Username   *string
	Token      *string
	Branch     *string
	Depth      *int
}

CloneConfiguration holds the configurations for cloning a repo

type IClient

type IClient interface {
	GetUserOrganization(login string) (*Owner, error)
	GetRepositoriesFromOwner(target Owner) ([]*Repository, error)
	GetOrganizationMembers(target Owner) ([]*Owner, error)
}

IClient interface is used with the api clients to hold the repo and org specific info.

type Logger

type Logger struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Logger holds specific configuration data for the logging

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

Debug prints a debug level log message to stdout

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

Error prints an error level log message to stdout

func (*Logger) Fatal

func (l *Logger) Fatal(format string, args ...interface{})

Fatal prints a fatal level log message to stdout

func (*Logger) Important

func (l *Logger) Important(format string, args ...interface{})

Important prints an important level log message to stdout

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

Info prints an info level log message to stdout

func (*Logger) Log

func (l *Logger) Log(level int, format string, args ...interface{})

Log is a generic printer for sending data to stdout. It does not do traditional syslog logging

func (*Logger) SetDebug

func (l *Logger) SetDebug(d bool)

SetDebug will configure the logger to enable debug output to be set to stdout

func (*Logger) SetSilent

func (l *Logger) SetSilent(s bool)

SetSilent will configure the logger to not display any realtime output to stdout

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{})

Warn prints a warn level log message to stdout

type Owner

type Owner struct {
	Login     *string
	ID        *int64
	Type      *string
	Name      *string
	AvatarURL *string
	URL       *string
	Company   *string
	Blog      *string
	Location  *string
	Email     *string
	Bio       *string
}

Owner holds the info that we want for a repo owner

type Repository

type Repository struct {
	Owner         *string
	ID            *int64
	Name          *string
	FullName      *string
	CloneURL      *string
	URL           *string
	DefaultBranch *string
	Description   *string
	Homepage      *string
}

Repository holds the info we want for a repo itself

Jump to

Keyboard shortcuts

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