heroku / cli

Heroku CLI
https://devcenter.heroku.com/articles/heroku-cli
ISC License
852 stars 223 forks source link

`heroku ci:run` needs explanatory warnings if the current git repo is in detached head state #1695

Open rpadaki opened 3 years ago

rpadaki commented 3 years ago

This project is for the Heroku CLI only and issues are reviewed as we are able. If you need more immediate assistence or help with anything not specific to the CLI itself, please use https://help.heroku.com.

Do you want to request a feature or report a bug?

Feature, I guess. Though it depends on whether one considers error handling/logging to be a feature or the lack thereof to be a bug.

What is the current behavior?

When running heroku ci:run from a detached head state, the Heroku CLI fails silently, leaving no explanation or warnings about the reasoning behind this behavior.

Suppose we're working on a git repo my-webserver, configured to deploy to the Heroku app my-heroku-webserver.

The following sequence of commands works fine:

cd my-webserver
git checkout dev
heroku ci:run --app my-heroku-webserver

The tests will build and run as configured, yay!

However, if we instead checkout to a specific commit and thus enter a detached head state:

cd my-webserver
git checkout 0a2dac
heroku ci:run --app my-heroku-webserver

Then the Heroku CLI exits silently with an exit code of 1. The error code 1 is not the issue here (see below) -- the issue is that there is no warning/error message or logging explaining the failure.

What is the expected behavior?

To be clear, I am NOT proposing that heroku ci:run should work in a detached head state -- we need to know the branch name, so it stands to reason that we must be on a branch. (For the details of what's exactly going on, we get the branch name here by calling git --symbolic-ref --short HEAD.)

However, it would probably be a good idea to either pass through the stderror from the git call to the user on failure or else to explain why the command is failing.

Until that's set up, I figured it might be good to get an issue up for this -- I ran into this while trying to run the Heroku CLI inside GitHub actions, which by default checks out a SHA, not a branch. Hopefully this can help others who are banging their heads against the same issue until the quick fix for this eventually works its way in.

djsavvy commented 3 years ago

I'd actually classify this as a bug, not a feature request.