IOS Code Review
(Code Review for IOS)The IOS app development team is a using Gerrit for code review. The following instructions assume you ' re using a recent version of Mac OS x. Contents[Hide]
- 1 New to Git?
- 2 Activate Your code review account
- 3 Get the code onto your machine
- 4 make changes and request a code review
- 5 Update Your code
- 6 When Gerrit fails to Submit Due to Merge Errors
- 7 when the Code Won ' t Run
- 8 git Tips and Tricks
- 8.1 squash multiple commits into one
- 8.2 Get rid of uncommitted changes
- 8.3 Reset your git repository to match the public repository
- 8.4 Set up Difftool and Mergetool
New to Git?If you were new to Git I suggest you take the time to read the first three chapters of the official Git book, this would sim Plify your life later. If you don ' t read the It now, at least come-to-it-thoroughly frustrated with Git. Here are a link to an introduction to the Gerrit Code Review tool. We have the come up with a Common Workflow, that would help you are more productive and avoid Common pitfalls. Please read and follow it. Here's an Activate Your code review account
- Sign in to the Code review website with your LDS account.
- Ask a admin for access to the project.
Get the code onto your machine
- If you haven ' t already do so, set up password caching.
- Clone the project you ' re working on (being sure to replace "project" in this and all further instructions with the name of th e actual project You "re working on). Use the Your LDS account password for this step (password caching makes it so you only has to use this password once):
git clone Https://tech.lds.org/mobile/codereview/p/PROJECT
- Clone Any libraries the project uses. Not all projects has them, but it doesn ' t hurt. Use the your LDS account credentials for this step.
CD projectgit submodule update--init--recursive
- set up a commit hook. This hook would automatically add the appropriate change ID to every commit. The change ID would help the code review tool to group multiple commits as a. This aids, the back and forth process of polishing, the code until it is a ready-to-be committed to the master repository. If you skip this step, you'll be unable to push, but it won ' t be obvious why.
curl https://tech.lds.org/mobile/codereview/tools/hooks/commit-msg >. git/hooks/commit-msgchmod u+x. git/hooks/ Commit-msg
- configure the git push command to request a code review. If you skip this step, you'll be unable to push.
git config Remote.origin.push head:refs/for/master
- set up your name and email. The e-mail would need to match who has registered in LDS Tech. If you skip this step, you'll be unable to push any commits make.
git config--global user.name "Your name" git config--global user.email "[email protected]" If you have alre Ady committed with the wrong information, can: git commit--amend--author= "author Name <[email protected]>" If There is multiple commits with the Wron G Information, follow these more in-depth steps.
Make changes and request a code review
- Make sure your ' re on Branch master:
git checkout Master
- Make sure your ' re working with the latest code:
Git pull Origin Master
- Create a new branch for your changes:
Git checkout-b <branchname>
- Make your changes.
- Verify Your changes:
git diffgit status
- commit your changes locally:
git commit-a You are asked to enter a commit message. Use the following format: (PROJECT-245) short summary of Change (~50 chars Max, issue ID in parentheses if applicable) A more elaborate summary of t He committed changes and suggested tests. May has bullet points or paragraphs. Break at chars. This is Shownwhen users view of the full commit.
- Request A code review:
git push You'll be asked to your username (LDS account username) and password (LDS account password).
We recommend you with GIT credential caching, here's how you set up git to cache your username and password. Update Your codeThe code review process exists to maintain a high level of code quality, to make sure that more than one set of eyes have s Een every line of code, and to provide a opportunity for both the contributor and the reviewer to learn. It is rare This any code review the request does not require some the change, even if minor. When that happens:
- Checkout the submitted code review.
- Find the "Download" option by going to your submitted code in Gerrit (the Code review tool) and scrolling down to the late St Patch set.
- Make sure the "Checkout" and "HTTP" options above the command is selected.
- Copy the git fetch https ... line next to ' Download ' and execute it in your terminal.
- Make your changes. Note:make sure you don't rebase your, as that makes it impossible to view only the differences in Gerrit.
- Verify Your changes:
git diffgit status
- Commit and request another code review. Do not use the- m argument for commit as this would overwrite the change ID. Update the commit description in the editor.
git commit-a--amendgit push
When Gerrit fails-to- Submit Due to Merge ErrorsIf you get the error ' Your change could not being merged due to a path conflict ' when submitting a change set in the Code rev Iew tool, need to resolve the conflict by following these steps:
- Make sure your Master branch are up to date: Git pull Origin master
- Checkout the conflicting change set. You can copy/paste the correct command from the ' Download ' sections in the Code review tool. It'll look something-like: git fetch https://[email protected]/mobile/codereview/project refs/changes/08 /8/2 && git checkout fetch_head
- Rebase against Master (this should give a conflict warning): git ok! master
- If you haven ' t already do so, set up your Mergetool (see related sections in Tips and Tricks).
- Run git mergetool to resolve the conflicts. Save and close each file.
- Tell the rebase-continue now, the issue is resolved: git rebase--continue
- Push the resolved conflict for review: git push
- Re-review the change set in the Code review tool, and then submit the changes to is merged to master.
When the Code Won ' t RunMany build/run problems can be solved by doing one or all of the following:
- In the Git repository, run git submodule update--init--recursive
- In the iOS Simulator click on "iOS Simulator", "Reset Content and Settings ..."
- In Xcode, type command-option-shift-k (or alternately, hold option and selecting "Product", "clean")
Git Tips and Trickssquash multiple commits into one
- Supply the parent of the last commit want to edit (for example 3):
Git rebase-i head~3 (That ' s dash I and tilde 3)
- You should see a list of commits in your text editor you'll want to change the commits you ' d like to squash from ' pick ' to ' s;:
Pick F7F3F6D changed my name a bits 310154e updated README formatting and added blames A5f4a0d added Cat-file
- Save and exit your text editor
: Wq
- All your commit messages and be shown. Combine them into a message, making sure you only has one change-id.
- Magic happens! And your commits is squashed.
- If the short version above isn ' t sufficient for your purposes, you can visit the link for more details. Learn about interactive rebasing for more details (specifically the sections about squashing commits).
Get rid of uncommitted changesWarning:this would lose all of your uncommitted or unstashed changes. To get rid of uncommitted changes, perform git reset--hard HEAD. If you want to get rid of the them temporarily, do git stash. Reset your git repository to match the public repositoryWarning:these steps would get rid of all of your unpublished changes on the branch you perform this on, even if they has been committed to that branch. (If They has been committed to a separate branch or stashed (Google "git stash"), they should is fine, but being careful.) If you get in a state so you don ' t like and you want to blow away your changes and get to a clean state, follow these Steps on your preferred branch (most likely branch master):
- Get rid of unwanted commits by performing git reset--hard head~<number>. Replace <number> with a value slightly more than the number of unwanted commits you want to get rid of. For instance, if you see the from your git log so you had 3 commits want to blow away and then git reset--ha Rd Head~5 would do the trick. (Note the tilde)
- Update to public repository-performing Git pull Origin master.
If this doesn ' t work, use one of the destructive blunt instruments described on Stack Overflow. Set up Difftool and Mergetoolgit config--global diff.tool opendiff git config--global merge.tool opendiff By default, Mergetool keeps ". Orig" Backup files. To disable this, run git config--global mergetool.keepbackup false. This page is last modified on 4 December, at 15:15.This page has been accessed 6,903 times. |