-
Notifications
You must be signed in to change notification settings - Fork 26
Tips & Tricks
This file contains tips and tricks commonly used in the runbox7 development.
Some times in the day to day work, git gets in the way. For example after some commits when the code is pushed to github runbox7 account, Travis CI complains about a wrong format git commit message. How should this be fixed ?
This document will try to provide some help for problems the runbox7 developers encounter.
If you ever need to synchronize your fork with the oficial runbox7 master branch, do the following:
git clone https://github.com/runbox/runbox7.git #clone the runbox7 project
cd runbox7 #move into runbox7direcrory
git remote add upstream https://github.com/runbox/runbox7.git
git checkout master #checks out the master branch from user repo
git pull origin master #pull from repo to sync master branch
git fetch upstream #fetches the "upstream" (runbox7 oficial repo)
git rebase upstream/master #rebases master with the upstream/master branch
This happens when someone forks a branch from your project, makes some commits and you want to merge those into your branch.
cd runbox7
git remote add upstream-target_user https://github.com/target_user/runbox7.git #add upstream for target_user
git fetch upstream-target_user #fetches target_user repo updates
git checkout -b target_user_branch #create a localbranch
git rebase upstream-geir/target_user_branch #rebase my branch with "upstream-target_user"/runbox7-feature-profiles branch
cd runbox7
RUNBOX7_ANGULAR_BACKEND_HOST='https://localhost/' ./node_modules/.bin/ng serve --poll=2000 --live-reload --progress --watch --aot --proxy-config backend-proxy-remote.conf.js runbox7
Sometimes, the development server does not start. Try the following command and start the server again
npm ci
Its important to verify that linting is correct before the git push. Otherwise Travis CI will complain. Run the following command to check lint and make sure travis will pass the reuslts.
npm run lint
Lint one part of the ci-tests.
To make sure travis will not throw some error in your code, run the ci-tests locally before a git push
npm run ci-tests
Another part of ci-tests is the headless browser tests which can also be run manually via the command:
CHROME_BIN=chromium-browser npm run test -- --watch=false --progress=false --browsers=ChromeHeadlessCI
Suppose you made lots of commits with wrong messages and now travis complains that commit messages are in the wrong format. There are a couple of ways to solve this problem. One way to do this, use git log to list the latest commits and find the last good one. Then reset soft to that commit id. then commit everything again with the correct commit messages.
git log
git reset --soft $commit-id #this will "uncommit" but keep the changes until that commit.
#It will allow you to commit the changes again.
#Use the correct format this time
git status .
git commit -m 'feat(Something): Correct message format' ....
git push origin $branch_name$
git push --force origin $branch_name$ #force may be needed to overwrite the changes commited
Of course there are other solutions for this. Another solution is to use rebase with "reword" as the example below:
- Use git log to count how many commits until the wrong commit message
git log
- rebase to that head:
git rebase -i HEAD~n -- where n is from step#1
- it will open the commit messages ie.
pick ababe2 One commit message here
pick beefba Another commit message <- want to change this one
- it needs "pick" to be change to "reword"
pick ababe2 One commit message here
reword beefba Another commit message <- changed from "pick" to "reword"
- it will ask to edit the commit message. change, save and done.
If you want to change the last commit message, and you have not pushed yet, you can use ammend.
git commit --amend # git will ask the user to enter a new commit message