-
Notifications
You must be signed in to change notification settings - Fork 7
Demo a multi-repo task with 'git switch somebranch' #1
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
Comments
I found an ugly solution. If I do everything in a single front-end task, the git switch statements are respected.
|
@WesleyMConner you can make it a bit more readable like such: tasks:
- name: Set custom branches
command: |
# Array for REPO:BRANCH name(s).
# REPO resolves to `/workspace/REPO` directory.
repo_branch=(
proj-1:staging
proj-2:dev
proj-3:next
website:temp
)
for item in "${repo_branch[@]}"; do {
IFS=':' read -r repo branch <<<"${item}" || true
(
cd "/workspace/${repo}"
# Switch branch
git switch "${branch}"
# npm tasks
npm install
)
} done
|
Also, would it have been helpful if there was a additionalRepositories:
- url: https://github.com/gitpod-io/demo-multi-repo-backend
checkoutLocation: backend
branch: dev # Non-existent currently |
A 'branch' option on additionalRepositories would be ideal for my use case. I was killing and re-creating a number of Gitpod instances working through the logic. That churn would be less necessary with a built-in facility. As a rule, there are a few additional things I do, including: (1) Specify the workspaceLocation for vsCode and add subsequently add each participating repo to the referenced file. (2) Setting up a default per-repo terminal (in the proper directory). I suspect there will always be some of this tailoring. Any out-of-the-box automation is a plus. I am curious why the git switch couldn't be performed in a per-repo command section. It might be helpful to understand the startup model better to know why insertion in a per-repo command fails. Currently, I'm not using teams; so, haven't played with the teams-specific behavior. |
If you mean the snippet I shared, it's obviously doable, you're already following a similar method on your initial snippet. My last snippet was aimed at having the whole Here's another simpler example tailored to address tasks:
- name: Frontend
command: |
cd /workspace/frontend
git switch <branch>
npm install
- name: Backend
command: |
cd /workspace/backend
git switch <branch>
npm install
Is this what you mean? (I'm assuming you already saw this)
Agree! Could you please raise a feature request at https://github.com/gitpod-io/gitpod/issues/new/choose 🙏 ? |
Thanks for all of the follow up! When I tried the following (yesterday):
Yes, workspaceLocation is working fine as documented. [It's just a matter of remembering to add all repos and reload (not rebuild) the Gitpod instance.] |
That's odd 😅 What's the output of |
Is your feature request related to a problem? Please describe
I have not found a reliable way to set specific/different git branches for participating repositories using tasks in the multi-repo front end.
Describe the behaviour you'd like
On multi-repo startup, I would like to manually set the git branch of certain participants to a branch that is NEITHER the same as the branch of the multi-repo front end NOR the default branch of the participant.
Describe alternatives you've considered
I have tried creating tasks in the multi-repo front end's .gitpod.yml file that:
I change directory command is respected as is the npm install. The git switch command fails with "invalid reference". I have tried writing the task as a multi-line 'command' AND by breaking the lines into appropriate 'before', 'init' and 'command' components.
Additional context
I can perform the git switch manually, in a shell AFTER the new Multi-Repo gitpod session is fully launched. [It's just something else to remember to do.]
I suspect, but cannot confirm, that the timing of Multi-Repo's git clone and set branch activities may not be complete when the tasks are run.
The text was updated successfully, but these errors were encountered: