Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate requiring -a flag for all renaming operations #3200

Open
justinwilaby opened this issue Feb 3, 2025 · 2 comments
Open

Investigate requiring -a flag for all renaming operations #3200

justinwilaby opened this issue Feb 3, 2025 · 2 comments

Comments

@justinwilaby
Copy link
Contributor

justinwilaby commented Feb 3, 2025

The following comment was made on #3110 - This issue is to track this request and investigate

//-----------------------------------------

My apologies @eablack - In this case the -a flag is needed which I unintentionally omitted in the test instructions. Please try again with the updated instructions.

@justinwilaby I was playing with this today and found if I'm inside my apps git repository, and have a heroku remote, I can run heroku apps:rename new-example-app without -a, and so still get the behaviour of the remote being deleted. If I don't have a remote, it does give the Missing required flag app error.

I wonder if -a should be required, even when you have a single heroku remote, if that's the only way to ensure the renaming happens? CLI help does already say that it is: (-a, --app=<value> (required) app to run command against) but seems not in this circumstance (similar to heroku apps:info, etc).

I guess even nicer would be if it renamed it without -a in circumstances where that is allowed (I assume when there is only one remote?).

Originally posted by @jmasson in #3110 (comment)

//-------------------------------------------

@sbosio
Copy link
Contributor

sbosio commented Feb 4, 2025

Hi @jmasson, the behavior you described is just how the Heroku CLI operates to determine the target app for any command requiring the --app value to be provided.

When the --app option is required for any command but you don't explicitly provide that value on the command line, Heroku CLI will attempt to auto-detect it from the Git remotes configured only if you happen to be inside a local Git repository with a single remote targeting a Heroku Git host. If it founds a single remote configured, then the target app name will be set by default.

I.e. a command like the one you described: heroku apps:rename new-example-app it's expected to work if you were inside a local Git repo with a single Heroku remote configured (e.g. heroku https://git.heroku.com/old-example-app.git) and after the command runs, the old remote should've been removed and re-targeted at heroku https://git.heroku.com/new-example-app.git. Is that the behavior you observed or were there any issues renaming the app or re-targeting the Git remote to the new app name?

@jmasson
Copy link

jmasson commented Feb 13, 2025

Hi @sbosio,

I was attempting to rename the app, from within the git repo. As you said, I didn't think I would need to provide the --app or -a option because I am in the git repo, and I don't need to for the rename to work successfully, but if I don't, then the git remote isn't updated for me as expected, the heroku remote is just removed.

Here's a bit fuller explanation of what I did/observed:

Steps to reproduce

  1. Create a new app from the CLI
  2. Do a git remote -v and observe there is a heroku remote listed
  3. Rename the app from within the git repo, without the -a flag - e.g. heroku apps:rename new-example-app
  4. Do a git remote -v

Expected behaviour
As per the documentation:

If you use the Heroku CLI to rename an app from inside its associated Git repository, your local Heroku remote is updated automatically.
and the reminder from the CLI:
Warning: Don't forget to update git remotes for all other local checkouts of the app.
both confirm that the git remote should retain heroku entries with the URL upgraded to the new name in the current git repo, you should only need to update it on others.

Actual behaviour
The heroku remote has been removed.

Terminal output for above steps:

% git remote -v
heroku	https://git.heroku.com/kilterset-fir-ruby.git (fetch)
heroku	https://git.heroku.com/kilterset-fir-ruby.git (push)
origin	https://github.com/heroku/ruby-getting-started.git (fetch)
origin	https://github.com/heroku/ruby-getting-started.git (push)

% heroku apps:rename kilterset-fir-ruby-rename
Renaming kilterset-fir-ruby to kilterset-fir-ruby-rename... done
https://kilterset-fir-ruby-59039a6c93c1.herokuapp.com/ | https://git.heroku.com/kilterset-fir-ruby-rename.git
 ›   Warning: Don't forget to update git remotes for all other local checkouts of the app.

% git remote -v
origin	https://github.com/heroku/ruby-getting-started.git (fetch)
origin	https://github.com/heroku/ruby-getting-started.git (push)
%

Hope that helps, let me know if I can add any more details at all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants