|
9 | 9 | "runtime" |
10 | 10 | "syscall" |
11 | 11 |
|
12 | | - "github.com/mitchellh/go-homedir" |
13 | 12 | "gopkg.in/yaml.v3" |
14 | 13 | ) |
15 | 14 |
|
@@ -93,37 +92,25 @@ func DataDir() string { |
93 | 92 | var errSamePath = errors.New("same path") |
94 | 93 | var errNotExist = errors.New("not exist") |
95 | 94 |
|
96 | | -// Check default paths (os.UserHomeDir, and homedir.Dir) for existing configs |
| 95 | +// Check default path, os.UserHomeDir, for existing configs |
97 | 96 | // If configs exist then move them to newPath |
98 | | -// TODO: Remove support for homedir.Dir location in v2 |
99 | 97 | func autoMigrateConfigDir(newPath string) error { |
100 | 98 | path, err := os.UserHomeDir() |
101 | 99 | if oldPath := filepath.Join(path, ".config", "gh"); err == nil && dirExists(oldPath) { |
102 | 100 | return migrateDir(oldPath, newPath) |
103 | 101 | } |
104 | 102 |
|
105 | | - path, err = homedir.Dir() |
106 | | - if oldPath := filepath.Join(path, ".config", "gh"); err == nil && dirExists(oldPath) { |
107 | | - return migrateDir(oldPath, newPath) |
108 | | - } |
109 | | - |
110 | 103 | return errNotExist |
111 | 104 | } |
112 | 105 |
|
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) |
114 | 107 | // If state file exist then move it to newPath |
115 | | -// TODO: Remove support for homedir.Dir location in v2 |
116 | 108 | func autoMigrateStateDir(newPath string) error { |
117 | 109 | path, err := os.UserHomeDir() |
118 | 110 | if oldPath := filepath.Join(path, ".config", "gh"); err == nil && dirExists(oldPath) { |
119 | 111 | return migrateFile(oldPath, newPath, "state.yml") |
120 | 112 | } |
121 | 113 |
|
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 | | - |
127 | 114 | return errNotExist |
128 | 115 | } |
129 | 116 |
|
@@ -181,26 +168,10 @@ func ParseDefaultConfig() (Config, error) { |
181 | 168 | func HomeDirPath(subdir string) (string, error) { |
182 | 169 | homeDir, err := os.UserHomeDir() |
183 | 170 | 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 | | - } |
188 | 171 | return "", err |
189 | 172 | } |
190 | 173 |
|
191 | 174 | 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 | | - |
204 | 175 | return newPath, nil |
205 | 176 | } |
206 | 177 |
|
|
0 commit comments