Skip to content

Commit

Permalink
Temporary save of bad implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dm3ch committed Jul 3, 2019
1 parent 5d36fbd commit 31e9fed
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

const (
profileExtention = "profile"
profileComment = "git-profile-manager: Do not remove"
)

// Create directory if it doesn't exists
Expand Down
44 changes: 42 additions & 2 deletions cmd/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"github.com/spf13/cobra"
)

type include struct {
Paths []string `ini:"path,omitempty,allowshadow"`
}

var useCmd = &cobra.Command{
Use: "use [profile name]",
Short: "Use specified profile for current repo",
Expand All @@ -30,14 +34,50 @@ var useCmd = &cobra.Command{
os.Exit(1)
}

section, err := gitConfig.NewSection("include")
incSection, err := gitConfig.NewSection("include")
if err != nil {
fmt.Println("Can't get profile section:")
fmt.Println(err)
os.Exit(1)
}

section.NewKey("path", path)
inc := new(include)
err = incSection.MapTo(inc)
if err != nil {
fmt.Println("Can't map include section:")
fmt.Println(err)
os.Exit(1)
}

// inc.Paths = append(inc.Paths[:1], inc.Paths[1+1:]...)

err = incSection.ReflectFrom(inc)
if err != nil {
fmt.Println("Can't reflect include section:")
fmt.Println(err)
os.Exit(1)
}

// _, err = section.NewKey("path", path)
// if err != nil {
// fmt.Println("Can't set include.path key:")
// fmt.Println(err)
// os.Exit(1)
// }

// section, err = gitConfig.NewSection("profile")
// if err != nil {
// fmt.Println("Can't get profile section:")
// fmt.Println(err)
// os.Exit(1)
// }

// key, err := section.Key("path", path)
// if err != nil {
// fmt.Println("Can't set include.path key:")
// fmt.Println(err)
// os.Exit(1)
// }

gitconfig.SaveLocalConfig(gitConfig)
},
Expand Down
2 changes: 1 addition & 1 deletion gitconfig/gitconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func loadConfig(path string) (*ini.File, error) {
cfg, err := ini.Load(path)
cfg, err := ini.ShadowLoad(path)
return cfg, err
}

Expand Down

0 comments on commit 31e9fed

Please sign in to comment.