gitconfig

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: MIT Imports: 14 Imported by: 11

README

gitconfig

Test Status codecov.io MIT License PkgGoDev

gitconfig is a package to get configuration values from gitconfig.

Synopsis

val, err := gitconfig.Get("section.value")
if err != nil && !gitconfig.IsNotFound(err) {
    return err
}

// detect GitHub username from various informations
u, err := gitconfig.GitHubUser("")

Description

Installation

% go get github.com/Songmu/gitconfig

Author

Songmu

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(key string) (bool, error)

Bool gets a value as bool

func Do

func Do(args ...string) (string, error)

Do the git config

func Email

func Email() (string, error)

Email takes git email

func Get

func Get(args ...string) (string, error)

Get a value

func GetAll

func GetAll(args ...string) ([]string, error)

GetAll values

func GitHubToken

func GitHubToken(host string) (string, error)

GitHubToken takes API token for GitHub

func GitHubUser

func GitHubUser(host string) (string, error)

GitHubUser detects user name of GitHub from various informations

func Int

func Int(key string) (int, error)

Int get a value as int

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns a boolean indicating whether the error is known to report that a value does not found.

func Path

func Path(key string) (string, error)

Path gets a value as path

func PathAll

func PathAll(key string) ([]string, error)

PathAll get all values as paths

func User

func User() (string, error)

User takes git user name

func WithConfig

func WithConfig(tb testing.TB, configContent string) func()

WithConfig is test helper to replace gitconfig temporarily

Types

type Config

type Config struct {
	System, Global, Local bool
	File                  string
	Cd                    string
	GitPath               string
}

Config is for base setting for git config

func (*Config) Bool

func (c *Config) Bool(key string) (bool, error)

Bool gets a value as bool

func (*Config) Do

func (c *Config) Do(args ...string) (string, error)

Do the git config

func (*Config) Email

func (c *Config) Email() (string, error)

Email takes git email

func (*Config) Get

func (c *Config) Get(args ...string) (string, error)

Get a value

func (*Config) GetAll

func (c *Config) GetAll(args ...string) ([]string, error)

GetAll values

func (*Config) GitHubToken

func (c *Config) GitHubToken(host string) (string, error)

GitHubToken takes API token for GitHub

func (*Config) GitHubUser

func (c *Config) GitHubUser(host string) (string, error)

GitHubUser detects user name of GitHub from various informations

func (*Config) Int

func (c *Config) Int(key string) (int, error)

Int get a value as int

func (*Config) Path

func (c *Config) Path(key string) (string, error)

Path gets a value as path

func (*Config) PathAll

func (c *Config) PathAll(key string) ([]string, error)

PathAll get all values as paths

func (*Config) User

func (c *Config) User() (string, error)

User takes git user name

Jump to

Keyboard shortcuts

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