internal

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package internal Copyright © 2024 Shieldine Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /*

Package internal Copyright © 2024 Shieldine Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /*

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddProfile

func AddProfile(profile models.ProfileConfig) error

func CheckGitRepo

func CheckGitRepo() bool

CheckGitRepo checks if the current directory is inside a Git repository. Returns true if inside a Git repository, false otherwise.

func ClearConfig

func ClearConfig() error

func DeleteProfile

func DeleteProfile(profileName string) error

func EditProfile

func EditProfile(profileName string, updatedProfile models.ProfileConfig) error

func GetAllProfiles

func GetAllProfiles() []models.ProfileConfig

func GetConfigPath

func GetConfigPath() string

func GetGlobalUserEmail added in v1.2.0

func GetGlobalUserEmail() (string, error)

GetGlobalUserEmail retrieves the global Git user.email configuration. Returns the email string or an error if the email is not set globally. Returns a custom NotSetError if the email is not configured globally.

func GetGlobalUserName added in v1.2.0

func GetGlobalUserName() (string, error)

GetGlobalUserName retrieves the global Git user.name configuration. Returns the username string or an error if the username is not set globally. Returns a custom NotSetError if the username is not configured globally.

func GetProfileByName

func GetProfileByName(profileName string) models.ProfileConfig

func GetProfilesByOrigin

func GetProfilesByOrigin(origin string) []models.ProfileConfig

func GetRepoOrigin

func GetRepoOrigin() (string, error)

GetRepoOrigin retrieves the origin URL of the Git repository and extracts the hostname. Returns the hostname (e.g., "github.com") from the remote origin URL. Returns an error if not in a Git repository or if the origin URL cannot be retrieved.

func GetUserEmail

func GetUserEmail() (string, error)

GetUserEmail retrieves the local Git user.email configuration. Returns the email string or an error if not in a Git repository or if the email is not set. Returns a custom NotSetError if the email is not configured locally.

func GetUserName

func GetUserName() (string, error)

GetUserName retrieves the local Git user.name configuration. Returns the username string or an error if not in a Git repository or if the username is not set. Returns a custom NotSetError if the username is not configured locally.

func LoadConfig

func LoadConfig() error

func SaveConfig

func SaveConfig() error

func SetConfigPath

func SetConfigPath(path string)

func SetUserEmail

func SetUserEmail(email string, global bool) error

SetUserEmail sets the Git user.email configuration. If global is true, sets the global configuration; otherwise sets local repository configuration. Returns an error if not in a Git repository (when global is false) or if the git command fails.

func SetUserName

func SetUserName(name string, global bool) error

SetUserName sets the Git user.name configuration. If global is true, sets the global configuration; otherwise sets local repository configuration. Returns an error if not in a Git repository (when global is false) or if the git command fails.

func UnsetUserEmail

func UnsetUserEmail(global bool) error

UnsetUserEmail removes the Git user.email configuration. If global is true, unsets the global configuration; otherwise unsets local repository configuration. Returns an error if not in a Git repository (when global is false), if no email is set, or if the git command fails.

func UnsetUserName

func UnsetUserName(global bool) error

UnsetUserName removes the Git user.name configuration. If global is true, unsets the global configuration; otherwise unsets local repository configuration. Returns an error if not in a Git repository (when global is false), if no username is set, or if the git command fails.

Types

type Config

type Config struct {
	Profiles []models.ProfileConfig `toml:"profiles"`
}
var (
	Conf Config
)

Jump to

Keyboard shortcuts

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