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

How to specify/checkout branch other than default #588

Open
js185606 opened this issue Apr 23, 2022 · 2 comments
Open

How to specify/checkout branch other than default #588

js185606 opened this issue Apr 23, 2022 · 2 comments

Comments

@js185606
Copy link

js185606 commented Apr 23, 2022

dev is the default branch in these 100 repos i'm trying to modify, but i'm trying to modify things in the qal branch for all of them. The search runs fine, but i'm not able to do a git checkout qal, i get an error about not matching any files, and i have tried the checkout step in the should_migrate, post_checkout, and even apply script. Here is my current config file:

id: 2022.04.22-cug01-init
title: create cug01 directories in qal branch of non-prod repos
adapter:
  type: github
  search_type: repositories
  search_query: org:ncr-digital-banking dbk-liftandshift in:name -non-prod in:name
hooks:
  should_migrate:
    - git fetch --all
    - git show-ref
    - git branch
    - git checkout qal
  post_checkout: ls -d wug02/
  apply:
    - $SHEPHERD_MIGRATION_DIR/cug01.sh
  pr_message: echo 'Adding cug01 files to repo'

and here is my apply script:

#!/bin/bash
set -ex
git show-ref
git remote -v
git checkout refs/remotes/origin/qal
git fetch --all
pwd
mkdir -p cug01/qal1
ls -la
ls -la wug02
cd wug02/qal1
tar -cvf env.tar .
mv env.tar ../../cug01/qal1/
cd ../../cug01/qal1/
tar -xvf env.tar

And here is the error during checkout (same happens during apply):

✔ Checked out repo
> Running should_migrate steps
$ git fetch --all
Fetching origin
Step "git fetch --all" exited with 0
$ git show-ref
e9a3b8f3f8ecc0f5b00f77d16eee8269e5a25d51 refs/heads/2022.04.22-cug01-init
e9a3b8f3f8ecc0f5b00f77d16eee8269e5a25d51 refs/heads/dev
e9a3b8f3f8ecc0f5b00f77d16eee8269e5a25d51 refs/remotes/origin/HEAD
e9a3b8f3f8ecc0f5b00f77d16eee8269e5a25d51 refs/remotes/origin/dev
Step "git show-ref" exited with 0
$ git branch
* 2022.04.22-cug01-init
  dev
Step "git branch" exited with 0
$ git checkout qal
error: pathspec 'qal' did not match any file(s) known to git
Step "git checkout qal" exited with 1
✖ Error running should_migrate steps; skipping
✖ Error running should_migrate steps; skipping

Some of the previous issues and PRs mention non-default branches, but in looking at the adapter code, there's clearly references to defaultBranch everywhere with no clear way to override it.
Any help is appreciated!

@js185606
Copy link
Author

I briefly thought i was able to "trick" shephard by using id: qal and it said that it checked out the qal branch, but when i checked, it had still checked out the default of dev...

@nwalters512
Copy link
Collaborator

Shepherd doesn't currently support this. Even if you manage to check out a different branch during the apply phase, none of the other commands will know about that and this won't work correctly.

Can you say a little more about why you're trying to work this way? This might be a reasonable ask, and in that case you'd be welcome to submit a PR for this!

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

No branches or pull requests

2 participants