gosick #1
@@ -191,6 +191,7 @@ type execAllCmd struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type rcCmd struct {
|
type rcCmd struct {
|
||||||
|
Force bool `help:"Bypass legacy .homesickrc safety confirmation."`
|
||||||
Castle string `arg:"" optional:"" name:"CASTLE" help:"Castle name."`
|
Castle string `arg:"" optional:"" name:"CASTLE" help:"Castle name."`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,12 +212,18 @@ func (c *pushCmd) Run(app *core.App) error { return app.Push(defaultCastle(c.Cas
|
|||||||
func (c *commitCmd) Run(app *core.App) error {
|
func (c *commitCmd) Run(app *core.App) error {
|
||||||
return app.Commit(defaultCastle(c.Castle), c.Message)
|
return app.Commit(defaultCastle(c.Castle), c.Message)
|
||||||
}
|
}
|
||||||
func (c *destroyCmd) Run(app *core.App) error { return app.Destroy(defaultCastle(c.Castle)) }
|
func (c *destroyCmd) Run(app *core.App) error { return app.Destroy(defaultCastle(c.Castle)) }
|
||||||
func (c *cdCmd) Run(app *core.App) error { return app.ShowPath(defaultCastle(c.Castle)) }
|
func (c *cdCmd) Run(app *core.App) error { return app.ShowPath(defaultCastle(c.Castle)) }
|
||||||
func (c *openCmd) Run(app *core.App) error { return app.Open(defaultCastle(c.Castle)) }
|
func (c *openCmd) Run(app *core.App) error { return app.Open(defaultCastle(c.Castle)) }
|
||||||
func (c *execCmd) Run(app *core.App) error { return app.Exec(c.Castle, c.Command) }
|
func (c *execCmd) Run(app *core.App) error { return app.Exec(c.Castle, c.Command) }
|
||||||
func (c *execAllCmd) Run(app *core.App) error { return app.ExecAll(c.Command) }
|
func (c *execAllCmd) Run(app *core.App) error { return app.ExecAll(c.Command) }
|
||||||
func (c *rcCmd) Run(app *core.App) error { return app.Rc(defaultCastle(c.Castle)) }
|
func (c *rcCmd) Run(app *core.App) error {
|
||||||
|
originalForce := app.Force
|
||||||
|
app.Force = c.Force
|
||||||
|
err := app.Rc(defaultCastle(c.Castle))
|
||||||
|
app.Force = originalForce
|
||||||
|
return err
|
||||||
|
}
|
||||||
func (c *generateCmd) Run(app *core.App) error { return app.Generate(c.Path) }
|
func (c *generateCmd) Run(app *core.App) error { return app.Generate(c.Path) }
|
||||||
|
|
||||||
func defaultCastle(castle string) string {
|
func defaultCastle(castle string) string {
|
||||||
|
|||||||
@@ -780,6 +780,10 @@ func (a *App) Rc(castle string) error {
|
|||||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
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
|
// If .homesickrc exists, ensure .homesick.d/parity.rb wrapper is created
|
||||||
// (but do not overwrite an existing parity.rb).
|
// (but do not overwrite an existing parity.rb).
|
||||||
if _, err := os.Stat(homesickRc); err == nil {
|
if _, err := os.Stat(homesickRc); err == nil {
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ func (s *RcSuite) TestRc_HomesickrcCreatesRubyWrapper() {
|
|||||||
castleRoot := s.createCastle("dotfiles")
|
castleRoot := s.createCastle("dotfiles")
|
||||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
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"))
|
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||||
|
|
||||||
@@ -151,6 +152,7 @@ func (s *RcSuite) TestRc_HomesickrcWrapperNotOverwrittenIfExists() {
|
|||||||
castleRoot := s.createCastle("dotfiles")
|
castleRoot := s.createCastle("dotfiles")
|
||||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||||
|
s.app.Force = true
|
||||||
|
|
||||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||||
require.NoError(s.T(), os.MkdirAll(homesickD, 0o755))
|
require.NoError(s.T(), os.MkdirAll(homesickD, 0o755))
|
||||||
@@ -171,6 +173,7 @@ func (s *RcSuite) TestRc_HomesickrcWrapperCreatedBeforeExecution() {
|
|||||||
castleRoot := s.createCastle("dotfiles")
|
castleRoot := s.createCastle("dotfiles")
|
||||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||||
|
s.app.Force = true
|
||||||
|
|
||||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||||
require.NoError(s.T(), os.MkdirAll(homesickD, 0o755))
|
require.NoError(s.T(), os.MkdirAll(homesickD, 0o755))
|
||||||
|
|||||||
Reference in New Issue
Block a user