Scope
Since nopCommerce 3.4, the project is now moved from Mercurial to Git. The following shows a little example on how to do it.
In this example, I am going to add a field in the DiscountBoxModel so that I can display different color if the discount is applied sucessfully or not. The fork is here.
Codeplex
Fork and pull request were previously discussed here.
http://tech.sunnyw.net/2013/11/contribute-to-mercurial-in-simple-steps.html
http://tech.sunnyw.net/2013/11/contribute-to-mercurial-in-simple-steps.html
Git
Clone
After we fork, the clone command will get latest from remote repository to the local directory.
$ git clone https://git01.codeplex.com/forks/swon/discountboxisapplied
C:\tfs\Nop34> git clone https://git01.codeplex.com/forks/swon/discountboxisapplied Cloning into 'discountboxisapplied'... remote: Counting objects: 111111, done. remote: Compressing objects: 100% (30586/30586), done. Receiving objects: 100% (111111/111111), 257.70 MiB | 706.00 KiB/s, done. emote: Total 111111 (delta 81017), reused 107610 (delta 78287) Resolving deltas: 100% (81017/81017), done. Checking connectivity... done Checking out files: 100% (5332/5332), done.We can verify by ls that we now have the files in local.
$ ls discountboxisapplied
Directory: C:\tfs\Nop34\discountboxisapplied Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 1/09/2014 5:22 PM src d---- 1/09/2014 5:19 PM upgradescripts -a--- 1/09/2014 5:19 PM 2473 .gitignore -a--- 1/09/2014 5:19 PM 980 README.md
Status
After I made some changes to my files in local, the status command will show me the pending changes.$ git status
# On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: src/Presentation/Nop.Web/Controllers/ShoppingCartController.cs # modified: src/Presentation/Nop.Web/Models/ShoppingCart/ShoppingCartModel.cs # modified: src/Presentation/Nop.Web/Nop.Web.csproj # modified: src/Presentation/Nop.Web/Themes/DefaultClean/Content/styles.css # modified: src/Presentation/Nop.Web/Views/ShoppingCart/_DiscountBox.cshtml # no changes added to commit (use "git add" and/or "git commit -a")
Commit
The commit command will now commit my changes to the repository, but before that happens, this command will cause my editor to popup and I will be able to enter my commit message.
$ git commit -a
[master 6762145] Add an additional IsApplied field to indicate if discount code is applied successfully. 5 files changed, 11 insertions(+), 2 deletions(-)
Push
After committing to our local repository, the last thing to do is to synchronize the changes from our local repository to the remote repository. This is done by push.
$ git push
Counting objects: 35, done. Delta compression using up to 4 threads. Compressing objects: 100% (18/18), done. Writing objects: 100% (18/18), 1.68 KiB | 0 bytes/s, done. Total 18 (delta 14), reused 0 (delta 0) To https://git01.codeplex.com/forks/swon/discountboxisapplied 89f0ede..6762145 master -> master
Conclusion
Obviously there are more commands and options in Git. This article only showed the basic operations on how to contribute codes to an open source project.
As a developer that traveling between VSS, SVN, ClearCase, TFS, Mercurial and Git, I am not too excited about what tools are used, but rather what and how can be done. The way how fork and clone, push and pull are certainly innovative for open source platform. I found the commands were simple to use, and easy to remember. The experience was quite nice.
As a developer that traveling between VSS, SVN, ClearCase, TFS, Mercurial and Git, I am not too excited about what tools are used, but rather what and how can be done. The way how fork and clone, push and pull are certainly innovative for open source platform. I found the commands were simple to use, and easy to remember. The experience was quite nice.
No comments:
Post a Comment