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

"Current branch is..." showing wrong branch #422

Closed
joelworsham opened this issue Jul 21, 2016 · 15 comments
Closed

"Current branch is..." showing wrong branch #422

joelworsham opened this issue Jul 21, 2016 · 15 comments

Comments

@joelworsham
Copy link

joelworsham commented Jul 21, 2016

I created a test repository here: https://github.com/joelworsham/test-github-updater-plugin/blob/develop/plugin.php. Dummy plugin with two branches, master and develop.

  1. I installed my plugin via github updater into a local dev site running WP version 4.6-beta1-37941.
  2. I did not set a branch, so it defaults to master.
  3. From the Plugins screen, I clicked on "try another branch" and selected develop.
  4. It re-installed properly with the correct files from the correct branch.
  5. Back at the Plugin screen, it says "Current branch is master, ...".

This is inaccurate. I confirmed the files that exist are indeed from develop and not from master.

Any more info I can provide let me know.

I really love this plugin, and I want to use it, but this is an inconvenient stopper for me.

@joelworsham
Copy link
Author

NOTE: This is also happening identically for a theme at https://github.com/joelworsham/test-github-updater

@afragen
Copy link
Owner

afragen commented Jul 21, 2016

The branch switch gets it's branch info from the GitHub Branch header. This header is optional for branch master but necessary for other branches. Just add it to your develop branches and everything should be good to go.

@joelworsham
Copy link
Author

So the intent is that I'd be modifying that header on every commit to various branches?

@afragen
Copy link
Owner

afragen commented Jul 22, 2016

No, the intent is in your develop branch to have GitHub Branch: develop, in your feature/something-really-awesome branch have the header GitHub Branch: feature/something-really-awesome. Your master branch can have the header GitHub Branch: master or nothing as the default if no header is present is to label branch = master.

You never need to change or set them again. You would just need to be careful on branch merging not to merge the branch header as you don't want it changed.

Take a look at the header branches in this project to get an idea of what I mean. Let me know if I can clear anything up further.

@curtisbelt
Copy link

So the intent is that I'd be modifying that header on every commit to various branches?

I thought this was weird too, @afragen . I'm in the same boat as @joelworsham , and you may recall I opened a similar ticket and was told the same thing. In the end, I haven't bothered babysitting the GitHub Branch header and just get used to the fact that the branch name is "wrong".

Since I'm the only one that deals with the staging servers where we have branch switching enabled, it's not a big deal for me. But just chiming in to put in my 2 cents that I also don't think it's ideal.

@afragen
Copy link
Owner

afragen commented Jul 22, 2016

The issue from my end is that there's no way for my code to differentiate what branch you're working on. I can download or switch to a specific branch but I have no method of querying that plugin/theme afterwards to identify the branch.

I haven't bothered babysitting the GitHub Branch header and just get used to the fact that the branch name is "wrong".

@curtisbelt I don't know what you mean by babysitting the branch header.

If there's some other method of querying an installed plugin/theme that will tell me what branch it is from, please send a PR.

@curtisbelt
Copy link

Apologies for my bluntness - if that's the only way it can be done then I understand. I don't personally know of a different way.

@afragen
Copy link
Owner

afragen commented Jul 22, 2016

Not to worry about the bluntness, I don't know of another way. As your plugin's code sits on your wp-content/plugins folder there is no way to determine which branch it came from. That's why the header exists.

@afragen
Copy link
Owner

afragen commented Jul 22, 2016

If I may ask a question, what problem do you have after adding the appropriate branch headers to the appropriate branches?

After I've merged develop into master, I just make sure that the branch header didn't merge too. If it did I change it back before pushing. I've only had to do this the first time I merged as every merge after doesn't seem to pick up that the branch header has changed.

@joelworsham
Copy link
Author

Perhaps it's due to my naivety, but when committing and merging branches, wouldn't that github header line be viewed as a change and something to be committed?

@afragen
Copy link
Owner

afragen commented Jul 25, 2016

Only the first time the merge happens. After that it's not registered as a change.

Before committing the merge from develop into master, make sure the branch is correct. If not, just fix before committing merge. After that I don't see branch header changes after merging.

Give it a test and see.

@afragen afragen closed this as completed Aug 11, 2016
@joelworsham
Copy link
Author

After using this for a while, I have noticed that, as I expected, when you open a new branch, update the branch header, commit, and then merge back (whether it be back into develop or master), the branch header is overridden, every time, from the branch I'm merging into it.

You're saying you don't have this issue? I can't understand how you don't. If I make a commit in a new branch, and part of that commit is to modify the branch header line, why wouldn't it affect the branch I'm merging into?

To my knowledge, there is no way to "skip" that line in a merge. If it's in the commit, it's coming over. I am forced to add an extra commit every time I merge branches, to fix the header. This really messes up tagging.

I'm really curious as to how you've avoided this issue.

@afragen
Copy link
Owner

afragen commented Aug 30, 2016

Let me try to describe my workflow as maybe that will help.

I usually have at minimum 2 branches, master and develop. Nothing goes into master except as a merge from develop. When I create a new branch to work on something from, it's usually a branch of develop. Depending upon whether or not others are using this new branch I may or may not set the 'GitHub Branch: develop' to the name of the actual branch.

When I'm done with this branch and have merged it into develop, if I've changed the branch header I will almost always need to correct the commit in develop as the branch header has changed. After this has happened once, merging doesn't seem to pick up on the change.

So, now I have develop which has been merged into master many times. Only on the first merge did I have to correct the master branch header. On every subsequent merge, and there have been hundreds, the branch header from develop does come over as a change. I imagine that somewhere this is recognized in .git as not a current change.

All this being said I use Tower or GitKraken to manage my git repos. I'm not sure how it would affect this issue.

It seems the issue is opening a new branch to merge back into master. Yes, the first time I open a new branch and rename the branch header I will have to reset it in another commit. PITA but I think that's just how git works.

tl;dr

I avoid the issue by not changing the branch header all the time and only merging develop into master.

@afragen afragen reopened this Aug 30, 2016
@joelworsham
Copy link
Author

That is my exact workflow. The "gitflow" workflow. Unfortunately the problem is still persistent for me. Merging from develop -> master replaces the branch header with develop. So odd.

I guess there's not much more that can be done about it though. I'll keep experimenting and trying to come up with a way to make this more consistent.

@afragen
Copy link
Owner

afragen commented Aug 31, 2016

In Tower, if you use a squash commit when merging from develop to master, the changes will show without being committed. You should then be able to fix the branch header before committing.

I think.

@afragen afragen closed this as completed Sep 15, 2016
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

3 participants