Skip to content
Jérôme Benoit edited this page Apr 26, 2020 · 77 revisions

Welcome to the ev-dashboard wiki!

Git history reset handling

Syncing with GitHub

  1. Do a copy of your local repositories
  2. Open a terminal or a PowerShell windows and go in the repository directory. Visual Code can do this for you automatically: Terminal -> New Terminal and choose the targeted local repository directory if needed
  3. Checkout master-qa branch: type git checkout master-qa (Visual Studio can probably also do it via a GUI)
  4. Type git reset --hard origin/master-qa to reset your local history index and tree in master-qa with the GitHub remote master-qa branch ones

Dealing with your local changes

In the local repositories, you will find all the local changes you've made in each of your branches. Now you want to report the changes made in your <topic-branch> on the history rewritten master-qa.

In the previously opened terminal in the targeted local repository:

  1. git checkout master-qa

  2. git branch -b <topic-branch-new-name>

  3. git checkout <topic-branch>

  4. git pull origin master-qa-old and fix eventual conflicts

  5. git diff -M origin/master-qa to visualise your changes

  6. If you're ok with the changes: git diff -M origin/master-qa > <topic-branch>.patch or continue editing until you're ok

  7. git checkout <topic-branch-new-name>

  8. git apply --ignore-space-change --ignore-whitespace <topic-branch>.patch
    If the patch doesn't apply, try:

    • on Windows: Get-Content .\<topic-branch>.patch | Set-Content -Encoding utf8 <topic-branch>-fixed.patch
    • on *nix: iconv -f ascii -t utf-8 <topic-branch>.patch -o <topic-branch>-fixed.patch
    • git apply --ignore-space-change --ignore-whitespace <topic-branch>-fixed.patch

    If it still doesn't apply, try: git apply --reject --whitespace=fix <topic-branch>.patch
    Then manually merge the rejection in *.rej files and delete them

  9. rm <topic-branch>.patch

Then you can work as usual on <topic-branch-new-name> and delete your old <topic-branch>.

Repeat for each of your branches.

Working with git submodule

Initialising

While cloning

git clone --recurse-submodules <repo-uri>

After cloning

git submodule --init --recursive

Syncing URIs

Must be executed after submodule repository URI changes in .gitmodules

git submodule sync

Updating

npm run git:supdate

Pushing including submodules

npm run git:spush

Diffing including submodules

npm run git:sdiff

Worklfow

Git submodules used in a repository are shown just as a first class repository in Visual Code and are indeed like any other git repository, so you can just treat them like any other git repository

Making changes to submodules

You'll have to keep in mind if you make changes to one submodule repository, you'll have to:

  • use a consistent naming for the branches in the main and the submodule repository
  • commit first yours changes in the submodule repository
  • ensure the main repository reference the commit id pointing to your latest changes in the submodule repository with git diff ou npm run git:sdiff
  • do two PRs: one on the main repository and one on the submodule repository

Git submodules paths in ev-server:

  • src/assets/configs-aws
  • src/integration/pricing/convergent-charging
  • src/integration/refund/concur
  • src/integration/smart-charging/sap-smart-charging
  • src/assets/charging-station-templates

So, carefully handled the changes you might do in that paths

Example: You have to make change on the SAP Smart Charging git submodule in ev-server:

  • create a branch from the up to date master-qa branch in the ev-server main repository: <feature-name>
  • create a branch from the up to date master-qa branch in the SAP Smart Charging git submodule repository with the same name: <feature-name>
  • do your changes that impact the both repositories and test them
  • commit your changes in the SAP Smart Charging git submodule repository and push them in the branch
  • commit your changes in the ev-server main repository and push them in the branch
  • do a PR from the branch on the SAP Smart Charging git submodule repository
  • do a PR from the branch on the ev-server main repository

The same goes on each submodules in ev-server impacted by your changes.

Keep submodules up to date

Most of the time, you'll just have to pull the submodules latest changes after a git pull on the main repository. You can do it one by one in Visual Code or run npm run git:supdate

Tips and tricks

Reseting submodules

git submodule foreach 'git reset --hard'

Checkout the same branch in each submodule

The targeted branch must exist.

git submodule foreach 'git checkout <branch-name>'

You get the point: git submodule foreach '<command>' allows you to run the same <command> in each submodule

Clone this wiki locally