Skip to content

Commit 2c02c28

Browse files
authored
Merge pull request cli#4145 from cli/remove-homedir
Remove backwards compatibility with homedir library for config files
2 parents 05328fb + 315c6e4 commit 2c02c28

File tree

3 files changed

+2
-34
lines changed

3 files changed

+2
-34
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ require (
2323
github.com/mattn/go-isatty v0.0.13
2424
github.com/mattn/go-runewidth v0.0.10
2525
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
26-
github.com/mitchellh/go-homedir v1.1.0
2726
github.com/muesli/termenv v0.8.1
2827
github.com/rivo/uniseg v0.2.0
2928
github.com/shurcooL/githubv4 v0.0.0-20200928013246-d292edc3691b

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ github.com/microcosm-cc/bluemonday v1.0.6/go.mod h1:HOT/6NaBlR0f9XlxD3zolN6Z3N8L
259259
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
260260
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
261261
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
262-
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
263-
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
264262
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
265263
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
266264
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=

internal/config/config_file.go

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"runtime"
1010
"syscall"
1111

12-
"github.com/mitchellh/go-homedir"
1312
"gopkg.in/yaml.v3"
1413
)
1514

@@ -93,37 +92,25 @@ func DataDir() string {
9392
var errSamePath = errors.New("same path")
9493
var errNotExist = errors.New("not exist")
9594

96-
// Check default paths (os.UserHomeDir, and homedir.Dir) for existing configs
95+
// Check default path, os.UserHomeDir, for existing configs
9796
// If configs exist then move them to newPath
98-
// TODO: Remove support for homedir.Dir location in v2
9997
func autoMigrateConfigDir(newPath string) error {
10098
path, err := os.UserHomeDir()
10199
if oldPath := filepath.Join(path, ".config", "gh"); err == nil && dirExists(oldPath) {
102100
return migrateDir(oldPath, newPath)
103101
}
104102

105-
path, err = homedir.Dir()
106-
if oldPath := filepath.Join(path, ".config", "gh"); err == nil && dirExists(oldPath) {
107-
return migrateDir(oldPath, newPath)
108-
}
109-
110103
return errNotExist
111104
}
112105

113-
// Check default paths (os.UserHomeDir, and homedir.Dir) for existing state file (state.yml)
106+
// Check default path, os.UserHomeDir, for existing state file (state.yml)
114107
// If state file exist then move it to newPath
115-
// TODO: Remove support for homedir.Dir location in v2
116108
func autoMigrateStateDir(newPath string) error {
117109
path, err := os.UserHomeDir()
118110
if oldPath := filepath.Join(path, ".config", "gh"); err == nil && dirExists(oldPath) {
119111
return migrateFile(oldPath, newPath, "state.yml")
120112
}
121113

122-
path, err = homedir.Dir()
123-
if oldPath := filepath.Join(path, ".config", "gh"); err == nil && dirExists(oldPath) {
124-
return migrateFile(oldPath, newPath, "state.yml")
125-
}
126-
127114
return errNotExist
128115
}
129116

@@ -181,26 +168,10 @@ func ParseDefaultConfig() (Config, error) {
181168
func HomeDirPath(subdir string) (string, error) {
182169
homeDir, err := os.UserHomeDir()
183170
if err != nil {
184-
// TODO: remove go-homedir fallback in GitHub CLI v2
185-
if legacyDir, err := homedir.Dir(); err == nil {
186-
return filepath.Join(legacyDir, subdir), nil
187-
}
188171
return "", err
189172
}
190173

191174
newPath := filepath.Join(homeDir, subdir)
192-
if s, err := os.Stat(newPath); err == nil && s.IsDir() {
193-
return newPath, nil
194-
}
195-
196-
// TODO: remove go-homedir fallback in GitHub CLI v2
197-
if legacyDir, err := homedir.Dir(); err == nil {
198-
legacyPath := filepath.Join(legacyDir, subdir)
199-
if s, err := os.Stat(legacyPath); err == nil && s.IsDir() {
200-
return legacyPath, nil
201-
}
202-
}
203-
204175
return newPath, nil
205176
}
206177

0 commit comments

Comments
 (0)