diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-05-24 09:15:51 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2020-05-24 09:15:51 +0200 |
commit | c80979499a2177f3e172b6d89dabaa0bf64e81d1 (patch) | |
tree | 53b50491cc72557cabc436f2784590cf449228d0 /_examples | |
parent | 936faa404ef02c88bde6a62663a6e1a4831c1fb3 (diff) | |
download | go-git-c80979499a2177f3e172b6d89dabaa0bf64e81d1.tar.gz |
Revert "Merge pull request #20 from quorumcontrol/feature/other-configs"
This reverts commit 3127ad9a44a2ee935502816065dfe39f494f583d, reversing
changes made to 73c52edaad2dae256be61bd1dbbab08e1092f58e.
Diffstat (limited to '_examples')
-rw-r--r-- | _examples/config/main.go | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/_examples/config/main.go b/_examples/config/main.go deleted file mode 100644 index 6ccc9f6..0000000 --- a/_examples/config/main.go +++ /dev/null @@ -1,69 +0,0 @@ -package main - -import ( - "github.com/go-git/go-git/v5" - . "github.com/go-git/go-git/v5/_examples" - format "github.com/go-git/go-git/v5/plumbing/format/config" - - "github.com/go-git/go-git/v5/config" -) - -// Example of how to: -// - Access basic local (i.e. ./.git/config) configuration params -// - Set basic local config params -// - Set custom local config params -// - Access custom local config params -// - Set global config params -// - Access global & system config params - -func main() { - // Open this repository - // Info("git init") - // r, err := git.Init(memory.NewStorage(), nil) - Info("open local git repo") - r, err := git.PlainOpen(".") - CheckIfError(err) - - // Load the configuration - cfg, err := r.Config() - CheckIfError(err) - - // Get core local config params - if cfg.Core.IsBare { - Info("repo is bare") - } else { - Info("repo is not bare") - } - - Info("worktree is %s", cfg.Core.Worktree) - - // Set basic local config params - cfg.Remotes["origin"] = &config.RemoteConfig{ - Name: "origin", - URLs: []string{"git@github.com:mcuadros/go-git.git"}, - } - - Info("origin remote: %+v", cfg.Remotes["origin"]) - - // NOTE: The examples below show advanced usage of the config.Merged system, which should - // only be used as a last resort if the basic data defined on the Config struct don't - // suffice for what you're trying to do. - - // Set local custom config param - cfg.Merged.AddOption(format.LocalScope, "custom", format.NoSubsection, "name", "Local Name") - - // Set global config param (~/.gitconfig) - cfg.Merged.AddOption(format.GlobalScope, "custom", format.NoSubsection, "name", "Global Name") - - // Get custom config param (merged in the same way git does: system -> global -> local) - Info("custom.name is %s", cfg.Merged.Section("custom").Option("name")) - - // Get system config params (/etc/gitconfig) - systemSections := cfg.Merged.SystemConfig().Sections - for _, ss := range systemSections { - Info("System section: %s", ss.Name) - for _, o := range ss.Options { - Info("\tOption: %s = %s", o.Key, o.Value) - } - } -} |