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

Setting upstream branch tracking info #116

Open
TrystanLea opened this issue Sep 26, 2019 · 17 comments
Open

Setting upstream branch tracking info #116

TrystanLea opened this issue Sep 26, 2019 · 17 comments

Comments

@TrystanLea
Copy link
Member

In attempting to automate the switching of the postprocess, device and sync modules to newly created stable branches I came across an issue caused by for some reason certain repositories not having upstream branch tracking info set. This meant I could not pull in all branches and switch to the newly created stable branches.

The solution I found to work was the following:
https://github.com/openenergymonitor/emonpi/compare/923e05deeb9ea5945b5493c665f21a20f6be182c..master

I needed to run:

git branch --set-upstream-to=origin/$branch

and then:

git pull

without the branch specific pull, it was then possible to run:

git checkout stable 

@borpin what do you think of this solution? Its a shame to pollute every emonpiupdate log with:

Branch stable set up to track remote branch stable from origin.

but it does seem to work well.

@TrystanLea
Copy link
Member Author

PS: @borpin im sure you will be happy with the new stable branches. Im thinking of adding a feature to select stable, master or auto from the emoncms UI to make switching between stable/master on a global level easier.

@borpin
Copy link
Contributor

borpin commented Sep 27, 2019

On changing from UI - great! I was thinking of an advanced update page that would allow a per repo brach selection option.

Not come across this problem with git. Can't try till Sunday. Can you tell me what you tried that failed?

Did you try a git fetch --all (from memory)?

Might be how the initial clone was done in the past. Is it a problem on a fresh scripted install?

@TrystanLea
Copy link
Member Author

Thanks @borpin yes I tried git fetch -all, not quite sure why that didnt work. Im also away until Sunday now. Will reply with more detail then.

@borpin
Copy link
Contributor

borpin commented Sep 30, 2019

So I have just had a go on an emonpi setup, created by the script (I think) a while back.

I've included a screenshot as the colour helps explain things.

TL:DR
It should work by simply using git fetch (not git pull) first which gets all of the repo info and then a git checkout <branch>. Caveat the git version is important as it was a feature added at some point.

The oddity is that it talks about a 'new' branch, but I don't think it really means that, rather that it has created a new local branch that is tracking a remote branch (if you see what I mean).

pi@emonpi:/var/www/emoncms $ cd Modules/device/
pi@emonpi:/var/www/emoncms/Modules/device $ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/emoncmsorg
  remotes/origin/indexedinputs
  remotes/origin/master
  remotes/origin/remove_user_dependency
pi@emonpi:/var/www/emoncms/Modules/device $ git fetch
From https://github.com/emoncms/device
 * [new branch]      stable     -> origin/stable
pi@emonpi:/var/www/emoncms/Modules/device $ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/emoncmsorg
  remotes/origin/indexedinputs
  remotes/origin/master
  remotes/origin/remove_user_dependency
  remotes/origin/stable
pi@emonpi:/var/www/emoncms/Modules/device $ git checkout stable
Branch stable set up to track remote branch stable from origin.
Switched to a new branch 'stable'
pi@emonpi:/var/www/emoncms/Modules/device $ git branch -a
  master
* stable
  remotes/origin/HEAD -> origin/master
  remotes/origin/emoncmsorg
  remotes/origin/indexedinputs
  remotes/origin/master
  remotes/origin/remove_user_dependency
  remotes/origin/stable
pi@emonpi:/var/www/emoncms/Modules/device $

image

Finally this looks correct.

pi@emonpi:/var/www/emoncms/Modules/device $ git remote show origin
* remote origin
  Fetch URL: https://github.com/emoncms/device
  Push  URL: https://github.com/emoncms/device
  HEAD branch: master
  Remote branches:
    emoncmsorg             tracked
    indexedinputs          tracked
    master                 tracked
    remove_user_dependency tracked
    stable                 tracked
  Local branches configured for 'git pull':
    master merges with remote master
    stable merges with remote stable
  Local refs configured for 'git push':
    master pushes to master (up to date)
    stable pushes to stable (up to date)

I will do the same for the postprocess folder...

pi@emonpi:/var/www/emoncms/Modules $ cd postprocess
pi@emonpi:/var/www/emoncms/Modules/postprocess $ git remote show origin
* remote origin
  Fetch URL: https://github.com/emoncms/postprocess
  Push  URL: https://github.com/emoncms/postprocess
  HEAD branch: master
  Remote branches:
    emoncmsorg tracked
    emonpi     tracked
    master     new (next fetch will store in remotes/origin)
    stable     new (next fetch will store in remotes/origin)
  Local branch configured for 'git pull':
    emonpi merges with remote emonpi
  Local ref configured for 'git push':
    emonpi pushes to emonpi (up to date)
pi@emonpi:/var/www/emoncms/Modules/postprocess $ git branch -a
* emonpi
  remotes/origin/HEAD -> origin/emonpi
  remotes/origin/emoncmsorg
  remotes/origin/emonpi
pi@emonpi:/var/www/emoncms/Modules/postprocess $ git fetch
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 18 (delta 7), reused 13 (delta 5), pack-reused 0
Unpacking objects: 100% (18/18), done.
From https://github.com/emoncms/postprocess
 * [new branch]      master     -> origin/master
 * [new branch]      stable     -> origin/stable
pi@emonpi:/var/www/emoncms/Modules/postprocess $ git branch -a
* emonpi
  remotes/origin/HEAD -> origin/emonpi
  remotes/origin/emoncmsorg
  remotes/origin/emonpi
  remotes/origin/master
  remotes/origin/stable
pi@emonpi:/var/www/emoncms/Modules/postprocess $ git remote show origin
* remote origin
  Fetch URL: https://github.com/emoncms/postprocess
  Push  URL: https://github.com/emoncms/postprocess
  HEAD branch: master
  Remote branches:
    emoncmsorg tracked
    emonpi     tracked
    master     tracked
    stable     tracked
  Local branch configured for 'git pull':
    emonpi merges with remote emonpi
  Local ref configured for 'git push':
    emonpi pushes to emonpi (up to date)
pi@emonpi:/var/www/emoncms/Modules/postprocess $ git checkout stable
Branch stable set up to track remote branch stable from origin.
Switched to a new branch 'stable'
pi@emonpi:/var/www/emoncms/Modules/postprocess $ git remote show origin
* remote origin
  Fetch URL: https://github.com/emoncms/postprocess
  Push  URL: https://github.com/emoncms/postprocess
  HEAD branch: master
  Remote branches:
    emoncmsorg tracked
    emonpi     tracked
    master     tracked
    stable     tracked
  Local branches configured for 'git pull':
    emonpi merges with remote emonpi
    stable merges with remote stable
  Local refs configured for 'git push':
    emonpi pushes to emonpi (up to date)
    stable pushes to stable (up to date)
pi@emonpi:/var/www/emoncms/Modules/postprocess $ git branch -a
  emonpi
* stable
  remotes/origin/HEAD -> origin/emonpi
  remotes/origin/emoncmsorg
  remotes/origin/emonpi
  remotes/origin/master
  remotes/origin/stable
pi@emonpi:/var/www/emoncms/Modules/postprocess $

@borpin
Copy link
Contributor

borpin commented Sep 30, 2019

As an aside, could you update all of the master branches so the version number is +1 & 'beta' please @TrystanLea?

@TrystanLea
Copy link
Member Author

updated version: emoncms/emoncms@b925f6e

@TrystanLea
Copy link
Member Author

I previously updated the versions for the other modules e.g: emoncms/sync@39361e4 just somehow forgot the main repo

@TrystanLea
Copy link
Member Author

If I run git fetch and then git checkout it gives me this message, so looks like git pull is required.

------------------------------------------
Updating /var/www/emoncms/Modules/wifi module
------------------------------------------
Fetching origin
- git branch: master
- git tags: 2.0.0-28-g16c75d2
- no local changes

Already on 'master'
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

@borpin
Copy link
Contributor

borpin commented Oct 1, 2019

I previously updated the versions for the other modules

It was other modules I found - Emoncms/device has the same version for master & stable.

I see you updated WiFi a few minutes ago but left off the 'beta' 😀.

@borpin
Copy link
Contributor

borpin commented Oct 1, 2019

If I run git fetch and then git checkout it gives me this message, so looks like git pull is required.

Use the prune command to help clean it up.

Yes, I think it will. I couldn't test that as stable and master were the same!

@borpin
Copy link
Contributor

borpin commented Oct 1, 2019

I think it is partly because the original clone targets a specific branch.

@TrystanLea
Copy link
Member Author

I see you updated WiFi a few minutes ago but left off the 'beta' grinning.

Yes I don’t want to add the beta to all modules, I think we just keep to updating the version on the module master branches after making a change and then merge to stable when ready.

@TrystanLea
Copy link
Member Author

Use the prune command to help clean it up.

prune command is already in there:

git fetch --prune --all

@borpin
Copy link
Contributor

borpin commented Oct 1, 2019

Yes I don’t want to add the beta to all modules

Ok but it then will get really confusing when looking at current state of Modules. At least a 'b' would immediately identify that the Module was pulled from master as opposed to stable.

@TrystanLea
Copy link
Member Author

I was thinking that we need to attach the branch to the version in the module list. That would be a good thing to add alongside the ability to change between stable/master on a global level via the UI.

@borpin
Copy link
Contributor

borpin commented Oct 1, 2019

Can do. Could also make it clearer what are 'core' and what are 'addons'.

One per line, perhaps hold a 'manifest' type file that lists all modules available and then the version number if installed in the UI.

Perhaps:

Module name (with URL) Version Branch Git Describe
Emoncms Version: low-write 10.1.7 master 10.1.6-125-g6274f797
backup v2.0.0 stable xxxxxxx

TBH I would not list the core modules, just the add-ons.

@TrystanLea
Copy link
Member Author

yes I think that would be really nice and I agree better without core modules, just the add-ons

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

No branches or pull requests

2 participants