Ovid/git-workflow

Teaching the scripts to use a base branch

Altreus opened this issue · 2 comments

I have some untested code in my fork https://github.com/Altreus/git-workflow so that the tools can use a base branch.

Currently they just use a different issue as the parent branch when checking out, and assume the format base-branch/feature-branch when doing their jobs.

This format doesn't apply to our git repos at work (we don't use github issues because Jira ... costs more?) so I've not actually tested it yet, but if you want it you can have it :)

Ovid commented

@Altreus If you provide changes as pull requests instead of a fork, it would be easier to evaluate as comment on.

In any event, what does this line do?

base="${branch%%/}";

It looks like you're trying to remove the trailing slash? That seems odd because git branch names don't allow a trailing slash. My bash knowledge isn't brilliant, so I assume I'm missing something here.

Thus, your base branch is always the current branch? If so, that seems like it violates the entire point of git refresh which is to always keep up to date with the latest master. Instead, you're trying to always keep up to date with the branch you're already on? Does that assume multiple collaborators per branch or something?

Ovid commented

I should have mentioned that a while ago, I've updated the code to detect the base branch you're working off of.

We derive the default branch via:

basename $( git symbolic-ref refs/remotes/origin/HEAD )

If you get the error, ref refs/remotes/origin/HEAD is not a symbolic ref,
you can fix it with this:

git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/$branch_name

Where $branch_name is the name of the primary branch you develop from
(main, master, etc.).

All scripts now output instructions on how to fix the symbolic ref error if it occurs.