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 ¶
- func AddProfile(profile models.ProfileConfig) error
- func CheckGitRepo() bool
- func ClearConfig() error
- func DeleteProfile(profileName string) error
- func EditProfile(profileName string, updatedProfile models.ProfileConfig) error
- func GetAllProfiles() []models.ProfileConfig
- func GetConfigPath() string
- func GetGlobalUserEmail() (string, error)
- func GetGlobalUserName() (string, error)
- func GetProfileByName(profileName string) models.ProfileConfig
- func GetProfilesByOrigin(origin string) []models.ProfileConfig
- func GetRepoOrigin() (string, error)
- func GetUserEmail() (string, error)
- func GetUserName() (string, error)
- func LoadConfig() error
- func SaveConfig() error
- func SetConfigPath(path string)
- func SetUserEmail(email string, global bool) error
- func SetUserName(name string, global bool) error
- func UnsetUserEmail(global bool) error
- func UnsetUserName(global bool) error
- type Config
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 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
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
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
)