lando / platformsh

The Official Platform.sh Lando Plugin
https://docs.lando.dev/platformsh
GNU General Public License v3.0
6 stars 4 forks source link

Platform.sh branch env variable stuck as master #43

Open scottfalkingham opened 3 years ago

scottfalkingham commented 3 years ago

The PLATFORM_BRANCH environment variable does not reflect the branch that is actually being used. It remains as master.

Investigating the code, it appears master is hardcoded when it generates /etc/profile.d/01-variables.sh.

https://github.com/lando/lando/blob/223635263301a55dd9f269d51bcb269229e14d07/integrations/lando-platformsh/lib/run.js#L138

To reproduce, check out a branch that is not master and run lando rebuild and then lando php -i | grep PLATFORM_BRANCH. It will return:

PLATFORM_BRANCH => master
$_SERVER['PLATFORM_BRANCH'] => master
$_ENV['PLATFORM_BRANCH'] => master
ddrager commented 3 years ago

I'll also note that my contacts at Platform.sh said that they are working to make the default branch 'main' soon, so this will need to be addressed because of that as well. Thank you.

pirog commented 3 years ago

@scottfalkingham @ddrager good to know. How are you all using PLATFORM_BRANCH? are you using it in your application code or for some other purpose?

scottfalkingham commented 3 years ago

@pirog it was going to be used in application code to toggle between development and production environments.

ptmkenny commented 2 years ago

I have a github repo (default branch: main) that is linked to platform.sh (also default branch: main).

This bug breaks the platform CLI.

Steps to reproduce

  1. Check out a feature branch my-dev-branch.
  2. Run lando platform environment:synchronize data -y.

What I expected: main to be downloaded into my local environment.

What happened:

  [InvalidArgumentException]               
  Specified environment not found: master                                         

EDIT:

This can be worked around by setting --environment my-dev-branch.