feat(rc): add --force guard for legacy homesickrc
This commit is contained in:
@@ -780,6 +780,10 @@ func (a *App) Rc(castle string) error {
|
||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
|
||||
if _, err := os.Stat(homesickRc); err == nil && !a.Force {
|
||||
return errors.New("refusing to run legacy .homesickrc without --force")
|
||||
}
|
||||
|
||||
// If .homesickrc exists, ensure .homesick.d/parity.rb wrapper is created
|
||||
// (but do not overwrite an existing parity.rb).
|
||||
if _, err := os.Stat(homesickRc); err == nil {
|
||||
|
||||
@@ -130,6 +130,7 @@ func (s *RcSuite) TestRc_HomesickrcCreatesRubyWrapper() {
|
||||
castleRoot := s.createCastle("dotfiles")
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||
s.app.Force = true
|
||||
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
|
||||
@@ -151,6 +152,7 @@ func (s *RcSuite) TestRc_HomesickrcWrapperNotOverwrittenIfExists() {
|
||||
castleRoot := s.createCastle("dotfiles")
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||
s.app.Force = true
|
||||
|
||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||
require.NoError(s.T(), os.MkdirAll(homesickD, 0o755))
|
||||
@@ -171,6 +173,7 @@ func (s *RcSuite) TestRc_HomesickrcWrapperCreatedBeforeExecution() {
|
||||
castleRoot := s.createCastle("dotfiles")
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||
s.app.Force = true
|
||||
|
||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||
require.NoError(s.T(), os.MkdirAll(homesickD, 0o755))
|
||||
|
||||
Reference in New Issue
Block a user