development workflow · github

17
In SymPy we encourage collaborative work. Everyone is welcome to join and to implement new feature, fix some bug, give general advice, etc. Also, we try to discuss everything and to review each other's work so that many eyes can see more thus raising the quality. General discussion takes place on [email protected] mailing list and in the issues. Some discussion also takes place on IRC (our channel is #sympy at freenode). As some of you already know, software development is not just coding. Many noncoding tasks have to be done in order to produce good code. For example: setting up infrastructure, designing, testing, documenting, assisting new developers (we are doing it here), and of course programming. But even programming is not all about writing the code, it is about writing the code and preparing it so that the code can be included in the project. Both producing the code and bringing it to the project are important parts of the game without the code there is nothing to bring in, and having the code outside is a nowin for anyone. As already said above, we review changes. This idea was borrowed from successful projects like Linux, Python, SAGE and many more. In short, each change is first reviewed by other developers and only when it is approved is the code pushed in. Like it takes effort to write good and clear code, reviewing other's work needs effort too. There are good practices how to do this so that reviewing is fun for both the author and the reviewer. We try to follow these good practices, and we'll try to show you how to follow them too. When reviewing other's patches you learn a lot, so why not participate as a reviewer too? Anyone regardless of technical skill can help review code, and it's an excellent way for newcomers to learn about Sympy's development process and community. License: New BSD License (see the LICENSE file for details) covers all files in the SymPy repository unless stated otherwise. There are a few ways to create and send a patch. The best way is to send a GitHub pull request against the sympy/sympy repository. We'll review it and push it in. The GitHub pull request is the preferred method, because it makes it easy for us to review and push the code in. More quickly, but not convenient for reviewing and merging, is to create a patchfile using git alone. This way can be used if the patch has a highpriority or is significant, only one or two files are involved, or you don't have enough time to use the preferred method. Although we are grateful for any improvements of Sympy, we strongly recommend you submit your patches as pull requests: this will greatly speed up the processing of the patch and ensure that it doesn't get forgotten due to inactivity. The basic workflow for both variants is a follows: 1. Create your environment, if it was not created earlier. 2. Create a new branch. Development workflow Introduction How to send a patch

Upload: p4patelkeyur

Post on 06-Nov-2015

27 views

Category:

Documents


0 download

DESCRIPTION

Development Workflow · GitHub

TRANSCRIPT

  • InSymPyweencouragecollaborativework.

    Everyoneiswelcometojoinandtoimplementnewfeature,fixsomebug,givegeneraladvice,etc.Also,wetrytodiscusseverythingandtorevieweachother'sworksothatmanyeyescanseemorethusraisingthequality.

    Generaldiscussiontakesplaceonsympy@googlegroups.commailinglistandintheissues.SomediscussionalsotakesplaceonIRC(ourchannelis#sympyatfreenode).

    Assomeofyoualreadyknow,softwaredevelopmentisnotjustcoding.Manynoncodingtaskshavetobedoneinordertoproducegoodcode.Forexample:settingupinfrastructure,designing,testing,documenting,assistingnewdevelopers(wearedoingithere),andofcourseprogramming.

    Butevenprogrammingisnotallaboutwritingthecode,itisaboutwritingthecodeandpreparingitsothatthecodecanbeincludedintheproject.

    Bothproducingthecodeandbringingittotheprojectareimportantpartsofthegamewithoutthecodethereisnothingtobringin,andhavingthecodeoutsideisanowinforanyone.

    Asalreadysaidabove,wereviewchanges.ThisideawasborrowedfromsuccessfulprojectslikeLinux,Python,SAGEandmanymore.Inshort,eachchangeisfirstreviewedbyotherdevelopersandonlywhenitisapprovedisthecodepushedin.

    Likeittakesefforttowritegoodandclearcode,reviewingother'sworkneedsefforttoo.Therearegoodpracticeshowtodothissothatreviewingisfunforboththeauthorandthereviewer.Wetrytofollowthesegoodpractices,andwe'lltrytoshowyouhowtofollowthemtoo.

    Whenreviewingother'spatchesyoulearnalot,sowhynotparticipateasareviewertoo?Anyoneregardlessoftechnicalskillcanhelpreviewcode,andit'sanexcellentwayfornewcomerstolearnaboutSympy'sdevelopmentprocessandcommunity.

    License:NewBSDLicense(seetheLICENSEfilefordetails)coversallfilesintheSymPyrepositoryunlessstatedotherwise.

    Thereareafewwaystocreateandsendapatch.

    ThebestwayistosendaGitHubpullrequestagainstthesympy/sympyrepository.We'llreviewitandpushitin.TheGitHubpullrequestisthepreferredmethod,becauseitmakesiteasyforustoreviewandpushthecodein.

    Morequickly,butnotconvenientforreviewingandmerging,istocreateapatchfileusinggitalone.Thiswaycanbeusedifthepatchhasahighpriorityorissignificant,onlyoneortwofilesareinvolved,oryoudon'thaveenoughtimetousethepreferredmethod.

    AlthoughwearegratefulforanyimprovementsofSympy,westronglyrecommendyousubmityourpatchesaspullrequests:thiswillgreatlyspeeduptheprocessingofthepatchandensurethatitdoesn'tgetforgottenduetoinactivity.

    Thebasicworkflowforbothvariantsisafollows:

    1. Createyourenvironment,ifitwasnotcreatedearlier.2. Createanewbranch.

    Developmentworkflow

    Introduction

    Howtosendapatch

  • 3. Modifycodeand/orcreatetestsofit.4. BesurethatalltestsofSymPypass.5. Onlythencommitchanges.6. Createpatchfile,orpullrequestfromGitHub.

    AllthosearedescribedinthedetailsbelowWorkflowprocess,butbeforeyoureadthat,itwouldbeusefultoacquaintyourselfwithCodingconventionsinSympy.

    Ifyouhaveanyquestionsyoucanaskthemonthemailinglist.

    FollowthestandardStyleGuideforPythonCodewhenwritingcodeforSymPy,asexplainedatthefollowingURLs:

    http://www.python.org/dev/peps/pep0008http://www.python.org/dev/peps/pep0257

    Inparticular,

    Use4spacesforindentationlevels.

    Usealllowercasefunctionnameswithwordsseparatedbyunderscores.Forexample,youareencouragedtowritePythonfunctionsusingthenamingconvention

    defset_some_value()

    insteadoftheCamelCaseconvention.

    UseCamelCaseforclassnamesandmajorfunctionsthatcreateobjects,e.g.

    classPolynomialRing(object)

    Note,however,thatsomefunctionsdohaveuppercaseletterswhereitmakessense.Forexample,formatricestheyareLUdecompositionorT(transposition)methods.

    prime'sdocstringisanexampleofawellformatteddocstring:

    """Returnthenthprime.

    Primesareindexedasprime(1)=2,prime(2)=3,etc....Thenthprimeisapproximatelyn*log(n)andcanneverbelargerthan2**n.

    SeeAlso========sympy.ntheory.primetest.isprime,primerange,primepi

    References==========..[1]http://primes.utm.edu/glossary/xpage/BertrandsPostulate.html

    Examples========>>>fromsympyimportprime>>>prime(10)29>>>prime(1)2

    """

    CodingconventionsinSympy

    StandardPythoncodingconventions

    Documentationstrings

  • FormoreinformationseeWritingdocumentationarticleonwiki.

    SymPyusesasinglecodebaseforPython2andPython3(thecurrentsupportedversionsarePython2.6,2.7,3.2,and3.3).ThismeansthatyourcodeneedstoruninbothPython2andPython3.

    Tomakethiseasier,therearemanyfunctionsinsympy.core.compatibilitythatshouldbeusedwhentherearedifferencesbetweenthetwoPythonversions.Toseewhatthingsyoucanimportfromthatfile,lookatitssource.

    IfyouneedtouseadditionalfunctionsormethodsthatchangenamesfromPython2toPython3,itisfarbettertoaddtosympy.core.compatibilityandimportfromtherethantobloatindividualsourcefileswithversionspecificlogic.Ingeneral,thePython3namesaretobepreferred,butthisisnotanabsoluterequirement.Forexample,thecurrentcodebaseusesxrangeextensively.

    Youshouldalsomakesurethatyouhave:

    from__future__importprint_function,division

    atthetopofeachfile.Thiswillmakesurethatprintisafunction,andthat1/2doesfloatingpointdivisionandnotintegerdivision.Youshouldalsobeawarethatallimportsareabsolute,soimportmodulewillnotworkifmoduleisamoduleinthesamedirectoryasyourfile.Youwillneedtouseimport.module.

    Creatingofenvironmentisonceonly.

    SymPyhasaharddependencyonthempmathlibrary(version>=0.19).Youshouldinstallitfirst,pleaserefertothempmathinstallationguide.

    ToinstallgitinLinuxlikesystemsyoucandoitviayournativepackagemanagementsystem:

    $yuminstallgit

    or:

    $sudoaptgetinstallgit

    InWindowssystems,firstofall,installPythonfrom:

    http://python.org/download/

    bydownloadingthe"Python2.7Windowsinstaller"(orPython2.6or2.5)andrunningit.ThendonotforgettoaddPythontothe$PATHenvironment.

    OnWindowsandMacOSX,theeasiestwaytogetgitistodownloadGitHub'ssoftware,whichwillinstallgit,andalsoprovideaniceGUI(thistutorialwillbebasedonthe

    Python3

    Workflowprocess

    Createyourenvironment

    Installmpmath

    Installgit

  • commandlineinterface).Note,youmayneedtogointotheGitHubpreferencesandchoosethe"InstallCommandLineTools"optiontogetgitinstalledintotheterminal.

    IfyoudodecidetousetheGitHubGUI,youshouldmakesurethatany"syncdoesrebase"optionisdisabledinthesettings.

    SympydevelopmentusesafewtoolsthatarenotincludedinabasicPythondistribution.Youwon'treallyneedthemuntilyouaregettingreadytosubmitapullrequest,buttosavetimelater,youcaninstall:

    Sphinxdocumentationgenerator(packagesphinxdoconDebianbasedsystems)Pythoncoveragelibrary(packagepythoncoverage)Programsneededforbuildingdocs,suchasrsvgconvert.Anuptodatelistisismaintainedindoc/README.rst

    Gittrackswhomakeseachcommitbycheckingtheusersnameandemail.Inaddition,weusethisinfotoassociateyourcommitswithyourGitHubaccount.

    Tosetthese,enterthecodebelow,replacingthenameandemailwithyourown(globalisoptional).:

    $gitconfigglobaluser.name"FirstnameLastname"$gitconfigglobaluser.email"[email protected]"

    Thenameshouldbeyouractualname,notyourGitHubusername.

    Theseglobaloptions(i.e.applyingtoallrepositories)areplacedin~/.gitconfig.Youcaneditthisfiletoaddsetupcolorsandsomehandyshortcuts:

    [user][email protected]

    [color]diff=autostatus=autobranch=autointeractive=true

    [alias]ci=commitdi=diffcolorwordsst=statusco=checkoutlog1=logpretty=onelineabbrevcommitlogs=logstat

    Itcanbeconvenientinfuturetotunethebashprompttodisplaythecurrentgitbranch.

    Theeasiestwaytodoit,istoaddthesnippetbelowtoyour.bashrcor.bash_profile:

    PS1="[\u@\h\W\$(gitbranch2>/dev/null|grepe'\*'|sed's/^..\(.*\)/{\1}/')]\$"

    Butbetteristousegitcompletionfromthegitsource.Thisalsohastheadvantageofaddingtabcompletiontojustabouteverygitcommand.Italsoincludesmanyotherusefulfeatures,forexample,promptings.Tousegitcompletion,firstdownloadthegitsourcecode(about27MiB),thencopythefiletoyourprofiledirectory:

    Installothersoftware

    Basicgitsettings

    Advancedtuning

  • $gitclonegit://git.kernel.org/pub/scm/git/git.git$cpgit/contrib/completion/gitcompletion.bash~/.gitcompletion.sh

    Readinstructionsin'~/.gitcompletion.sh'

    NotethatifyouinstallgitfromthepackagemanagerinmanyLinuxdistros,thisfileisalreadyinstalledforyou.Youcancheckifitisinstalledbyseeingiftabcompletionworksongitcommands(try,e.g.,gitcommi,orgitlogst).YoucanalsocheckifthePS1commandsworkbydoingsomethinglike:

    $PS1='\W$(__git_ps1"%s")\$'

    Andyourcommandpromptshouldchangetosomethinglike:

    sympymaster$

    Note,itisimportanttodefineyourPS1usingsinglequotes('),notdoublequotes("),orelsebashwillnotupdatethebranchname.

    AsyouaregoingtouseGitHubyoushouldhaveaGitHubaccount.Ifyouhavenotoneyetthensignupat:

    https://github.com/signup/free

    ThencreateyourownforkoftheSymPyproject(ifyouhavenotyet).GototheSymPyGitHubrepository:

    https://github.com/sympy/sympy

    andclicktheForkbutton.

    NowyouhaveyourownrepositoryfortheSymPyproject.IfyourusernameinGitHubismynickthentheaddressoftheforkedprojectwilllooksomethinglike:

    https://github.com/mynick/sympy

    SometoolsconnecttoGitHubwithoutSSH.TousethesetoolsproperlyyouneedtofindandconfigureyourAPIToken.

    OnGitHub,clickAccountSettingsthenAccountAdmin.

    CreateGitHubaccount

  • Enterthecodebelow,replacingthemynickand012apitokenwithyourown:

    $gitconfigglobalgithub.usermynick$gitconfigglobalgithub.token012apitoken

    Note:ifyoueverchangeyourGitHubpassword,anewtokenwillbecreatedandwillneedtobeupdated.

    Note:GitHubnolongerusesAPItokens.Youcanskipthisstep.

    OnyourmachinebrowsetowhereyouwouldliketostoreSymPy,andclone(download)thelatestcodefromSymPy'soriginalrepository(about20MiB):

    $gitclonegit://github.com/sympy/sympy.git$cdsympy

    Thenassignyourreadandwriterepotoaremotecalled"github":

    [email protected]:mynick/sympy.git

    FormoreinformationaboutGitHubforkingandtuningsee:[8],[9]and[11].

    ToestablishasecureconnectionbetweenyourcomputerandGitHubseedetailedinstructionsin[11].

    IfyouhaveanyproblemswithSSHaccesstoGitHub,readthetroubleshootinginstructionsat[12],oraskusinmaillist.

    Andnow,donotforgettogotothe`Createseparatedbranch`_instructionsbeforemodifyingthecode.

    YoumaywanttotakeadvantageofusingvirtualenvironmentstoisolateyourdevelopmentversionofSymPyfromanysystemwideinstalledversions,e.g.fromaptgetinstallpythonsympy.Therearetwoleadingvirtualenvironmenttools,virtualenvandconda.Condahastheadvantagethatallsoftwareinstallsarebinaryandthatyoucaneasilyswitchbetweenpythonversions.Hereisanexampleofusingcondatocreatetwodevelopmentvirtualenvironments,oneforpython2.7andoneforpython3.4:

    $condacreatensympydevpy27python=2.7mpmath>=0.19$condacreatensympydevpy34python=3.4mpmath>=0.19

    YounowhavetwoenvironmentsthatyoucanusefortestingyourdevelopmentcopyofSymPy.Forexample,cloneyourSymPyforkfromGithub:

    [email protected]:/sympy.git

    CloningSymPy

    SetupSSHkeys

    VirtualEnvironments

  • $cdsympy

    NowactivatethePython2.7environment:

    $sourceactivatesympydevpy27

    NotethatonWindowssourceisnotrequiredinthecommand.AndruntheSymPytests:

    (sympydevpy27)$bin/test

    Afterthetestsrun,thentrythetestsinthePython3.4environment:

    (sympydevpy27)$sourcedeactivate$sourceactivatesympydevpy34(sympydevpy34)$bin/test

    YoucanalsoinstallSymPyintotheenvironmentifyouwish(soyoucanusethedevelopmentversionfromanylocationonyourfilesystem):

    (sympydevpy34)$pythonsetup.pyinstall

    Ifyouprefervirtualenv,theprocessissimilar,excepttheswitchbetweenPython2and3isn'tassimple.

    Typically,youwillcreateanewbranchtobeginworkonanewissue.Alsopullrequestrelatedwiththem.

    Abranchnameshouldbrieflydescribethetopicofthepatchorpullrequest.Ifyouknowtheissuenumber,thenthebranchnamecouldbe,forexample,1234_sequences.Tocreateandcheckout(thatis,makeittheworkingbranch)anewbranch

    $gitbranch1234_sequences$gitcheckout1234_sequences

    orinonecommandusing

    $gitcheckoutb1234_sequences

    Toviewallbranches,withyourcurrentbranchhighlighted,type:

    $gitbranch

    Andremember,nevertypethefollowingcommandsinmaster:gitmerge,gitcommit,gitrebase.

    ...

    Donotforgetthatallnewfunctionalityshouldbetested,andallnewmethods,functions,andclassesshouldhavedoctestsshowinghowtousethem.

    Keepinmind,doctestsarenottests.Thinkofthemasexamplesthathappentobetested.Somekeydifferences:

    writedocteststobeinformativewriteregularteststocheckforregressionsand

    Createaseparatebranch

    Codemodification

  • cornercases.doctestscanbechangedatanytimeregulartestsshouldnotbechanged.

    Inparticular,weshouldbeabletochangeordeleteanydoctestatanytimeifitmakesthedocstringbettertounderstand.

    Toensureeverythingstaysinshape,letsseeifalltestspass:

    $./bin/test$./bin/doctest

    EachcommandwillshowaDONOTCOMMITmessageifanyofthetestsitrunsdoesnotpass.

    bin/testandbin/doctestdofasttests(thosethattakeseconds).You'llwanttorunthemwheneveryourcodeissupposedtoworkandnotbreakanything.

    Youcanalsorunbin/testslow,toruntheslowtests(thosethatmaytakeminuteseach).

    Codequality(unwantedspacesandindents)arecheckedby./bin/testutilitiestoo.Butyoucanseparatelyrunthistestwiththehelpofthiscommand:

    $./bin/testquality

    Ifyouhavetrailingwhitespaceitwillshowerrors.Thisonewillfixunwantedspaces.

    $./bin/strip_whitespace

    Ifyouwanttotestonlyonesetofteststry:

    $./bin/testsympy/concrete/tests/test_products.py

    Butrememberthatalltestsshouldpassbeforecommitting.

    NotethatalltestswillberunwhenyoumakeyourpullrequestautomaticallybyTravisCI,sodonotworrytoomuchaboutrunningeverypossibletest.Youcanusuallyjustrun:

    $./bin/testmod$./bin/doctestmod

    wheremodisthenameofthemodulethatyoumodified.

    Youcancheckwhatfilesarechanged:

    $gitstatus

    Addnewfilestotheindexifnecessary:

    $gitaddnew_file.py

    Checktotalchanges:

    $gitdiff

    BesurethatalltestsofSymPypass

    Committhechanges

  • Youarereadytocommitchangeslocally.Acommitalsocontainsacommitmessagewhichdescribesit.Seethenextsectionforguidelinesonwritinggoodcommitmessages.Type:

    $gitcommit

    Aneditorwindowwillappearautomaticallyinthiscase.InLinux,thisisvimbydefault.Youcanchangewhateditorpopsupbychangingthe$EDITORshellvariable.

    Alsowiththehelpofoptionayoucantellthecommandcommittoautomaticallystagefilesthathavebeenmodifiedanddeleted,butnewfilesyouhavenottoldgitaboutwillnotbeaffected,e.g.,:

    $gitcommita

    Ifyouwanttostageonlypartofyourchanges,youcanusetheinteractivecommitfeature.Justtype:

    $gitcommitinteractive

    andchoosethechangesyouwantintheresultinginterface.

    Thereareonlytwoformattingrulesforcommitmessages

    Thereshouldbeasinglelinesummaryof71charactersorlesswhichallowstheonelineformofthelogtodisplaythesummarywithoutwrapping.Acommonconventionistonotendthesummarywitha..Additionaldetailscanbegivenafterthesummary.Makesuretoleaveablanklineafterthesummaryandtokeepalllinesto78charactersorlesssotheycanbeeasilybereadinterminalswhichdon'tautomaticallywraplines.

    Hereisanexamplecommitmessage(fromthecommit[bf0e81e12a2f75711c30f0788daf4e58f72b2a41],whichispartoftheSymPyhistory):

    integrals:Improvedspeedofheurisch()andrevisedtests

    Improvedspeedofantiderivativecandidateexpansionandsolutionphasesusingexplicitdomainsandsolve_lin_sys().Theupsideofthischangeisthatlargeintegrals(thosethatgeneratelotsofmonomials)arenowcomputed*much*faster.ThedownsideisthatintegralsinvolvingDerivative()don'tworkanymore.I'mnotsureiftheyreallyusedtoworkproperlyoritwasjustacoincidenceand/orbadimplementation.Thisneedsfurtherinvestigation.

    Example:

    In[1]:fromsympy.integrals.heurischimportheurisch

    In[2]:f=(1+x+x*exp(x))*(x+log(x)+exp(x)1)/(x+log(x)+exp(x))**2/x

    In[3]:%timeratsimp(heurisch(f,x))CPUtimes:user7.27s,sys:0.04s,total:7.31sWalltime:7.32sOut[3]:2x2xx2logx+2x+2xlog(x)++2log(x)+log(x)1+2xx++log(x)

    Writingcommitmessages

  • Previouslyittook450secondsand4GBofRAMtocompute.

    Somethingstonoteaboutthiscommitmessage:

    Thefirstlinegivesabriefdescriptionofwhatthecommitdoes.ToolslikegitshortlogorevenGitHubonlyshowthefirstlineofthecommitbydefault,soitisimportanttoconveythemostimportantaspectsofthecommitinthefirstline.Thefirstlinehasintegrals:,whichgivescontexttothecommit.Acommitwon'talwaysbeseeninthecontextofyourbranch,soitisoftenhelpfultogiveeachcommitsomecontext.Thisisnotrequired,though,asitisnothardtolookatthecommitmetadatatoseewhatfilesweremodifiedoratthecommithistorytoseethenearbyrelatedcommits.Afterthefirstline,thereisaparagraphdescribingthecommitinmoredetail.Thisisimportant,asitdescribeswhatthecommitdoes,whichmightbehardtofigureoutjustfromlookingatthediff.Italsogivesinformationthatmightnotbeinthediffatall,suchasknownissues.SuchparagraphsshouldbewritteninplainEnglish.Commitmessagesareintendedforhumanreaders,bothforpeoplewhowillbereviewingyourcoderightnow,andforpeoplewhomightcomeacrossyourcommitinthefuturewhileresearchingsomechangeinthecode.Sometimes,bulletlistsareagoodformattoconveythechangesofacommit.Last,thereisanexample.Itisnicetogiveaconcreteexampleincommitsthataddnewfeatures.Thisparticularexampleisaboutimprovingthespeedofsomething,sotheexampleisabenchmarkresult.

    NotethatyoumayfeelfreetouseUnicodecharactersincommitmessages,suchasoutputfromtheSymPyUnicodeprettyprinter.

    Trytoavoidshortcommitmessages,like"Fix",andcommitmessagesthatgivenocontext,like"Foundthebug".Whenindoubt,alongercommitmessageisprobablybetterthanashortone.

    Besurethatyouareinyourownbranch,andrun:

    $gitpushgithub1234_sequences

    ThiswillsendyourlocalchangestoyourforkoftheSymPyrepository.Thennavigatetoyourrepositorywiththechangesyouwantsomeoneelsetopull:

    https://github.com/mynick/sympy

    Selectbranch,andpressthePullRequestbutton.

    AfterpressingthePullRequestbutton,youarepresentedwithapreviewpagewhereyoucanenteratitleandoptionaldescription,seeexactlywhatcommitswillbeincludedwhenthepullrequestissent,andalsoseewhothepullrequestwillbesentto:

    CreateapatchfileorpullrequestforGitHub

  • Ifyouresendingfromatopicbranch,thetitleisprefilledbasedonthenameofthebranch.Markdownissupportedinthedescription,soyoucanembedimagesorusepreformattedtextblocks.

    YoucanswitchtotheCommitstabtoensurethatthecorrectsetofchangesisbeingsent.AndreviewthediffofallchangesbyswitchingtotheFilesChanged.

    Enterabrieftitleandinthedescriptionrefertotheissueaddressedoranyrelatedissuesusingreferenceslike"#1234"thosereferencesautomaticallycreatelinksthathelpinthereviewofthepullrequest.

    Ifthereisn'tanissue,oneshouldbecreatedsoevenifthepullrequestgetsclosedthereisareferencetoitintheissues.Ifpossible,refertotheissuenumberinsuchaway,e.g."fixes#1234",thattheissuegetsclosedwhenthepullrequestgetscommitted.

    Onceyouveenteredthetitleanddescription,customizedthecommitrange,andreviewedthecommitsandfilechangestobesent,presstheSendpullrequestbutton.

    Thepullrequestissentimmediately.Youretakentothemainpullrequestdiscussionandreviewpage.Additionally,allrepositorycollaboratorsandfollowerswillseeaneventintheirdashboard.hThat'sall.

    SeealsoUpdatingyourpullrequest

    Ifafteratimeyouneedtomakechangesinpullrequestthenthebestwayistoaddanewcommitinyoulocalrepositoryandsimplyrepeatpushcommand:

    $gitcommit$gitpushgithub1234_sequences

    Notethatifyoudoanyrebasingorinanywayedityourcommithistory,youwillhavetoaddthef(force)optiontothepushcommandforittowork:

    $gitpushfgithub

    Youdon'tneedtodothisifyoumerge,whichistherecommendedway.

    Updatingyourpullrequest

  • Sometimes,youmayneedtomergeyourbranchwiththeupstreammaster.Usuallyyoudon'tneedtodothis,butyoumayneedtoif

    Someonetellsyouthatyourbranchneedstobemergedbecausetherearemergeconflicts.sympybottellsyouthatyourbranchcouldnotbemerged.Youneedsomechangefrommasterthatwasmadeafteryoustartedyourbranch.

    Note,thataftercloningarepository,ithasadefaultremotecalledoriginthatpointstothesympy/sympyrepository.Andyourforkremotenamedasgithub.Youcanobservetheremotesnameswiththehelpofthiscommand:

    [email protected]:mynick/sympy.git(fetch)[email protected]:mynick/sympy.git(push)origingit://github.com/sympy/sympy.git(fetch)origingit://github.com/sympy/sympy.git(push)

    Asanexample,considerthatwehavethesecommitsinthemasterbranchoflocalgitrepository:

    ABCmaster

    Thenwehavedivergentbranch1234_sequences:

    ABCmaster\ab1234_sequences

    Inthemeantimetheremotesympy/sympymasterrepositorywasupdatedtoo:

    ABCDorigin/masterABCmaster\ab1234_sequences

    Therearebasicallytwowaystogetuptodatewithachangedmaster:rebasingandmerging.Mergingisrecommended.

    Mergingcreatesaspecialcommit,calleda"mergecommit",thatjoinsyourbranchandmastertogether:

    ABCDorigin/master\\\Mmerge\/ab1234_sequences

    NotethatthecommitsA,B,C,andDfrommasterandthecommitsaandbfrom1234_sequencesremainunchanged.Onlythenewcommit,M,isaddedto1234_sequences,whichmergesinthenewcommitbranchfrommaster.

    Rebasingessentiallytakesthecommitsfrom1234_sequencesandreappliesthemonthelatestmaster,sothatitisasifyouhadmadethemfromthelatestversionofthatbranchinstead.Sincethesecommitshaveadifferenthistory,theyaredifferent(theywillhavedifferentSHA1hashes,andwilloftenhavedifferentcontent):

    ABCDa'b'origin/master

    Synchronizationwithmastersympy/sympy.

  • Rebasingisrequiredifyouwanttoedityourcommithistory(e.g.,squashcommits,editcommitmessages,removeunnecessarycommits).Butnotethatsincethisrewriteshistory,itispossibletolosedatathisway,anditmakesitharderforpeoplereviewingyourcode,becausetheycannolongerjustlookatthe"newcommits"theyhavetolookateverythingagain,becauseallthecommitsareeffectivelynew.

    Thereareseveraladvantagestomerginginsteadofrebasing.Rebasingreapplieseachcommititerativelyovermaster,andifthestateofthefileschangedbythatcommitisdifferentfromwhenitwasoriginallymade,thecommitwillchange.Thismeanswhatyoucanendupgettingcommitsthatarebroken,orcommitsthatdonotdowhattheysaytheydo(becausethechangeshavebeen"rebasedout").Thiscanleadtoconfusionifsomeoneinthefuturetriestotestsomethingbycheckingoutcommitsfromthehistory.Finally,mergeconflictresolutionscanbemoredifficultwithrebasing,becauseyouhavetoresolvetheconflictsforeachindividualcommit.Withmerging,youonlyhavetoresolvetheconflictsbetweenthebranches,notthecommits.Itisquitecommonforamergetonothaveanyconflictsbutforarebasetohaveseveral,becausetheconflictsare"alreadyresolved"bylatercommits.

    Mergingkeepseverythingintact.Thecommitsyoumakeareexactlythesame,downtotheSHA1hash,whichmeansthatifyoucheckoutacommitfromamergedbranch,itisexactlythesameascheckingitoutfromanonmergedbranch.Whatitdoesinsteadiscreateasinglecommit,themergecommit,thatmakesitsothatthehistoryisbothmasterandyourbranch.Thiscommitcontainsallmergeconflictresolutioninformation,whichisanotheradvantageoverrebasing(allmergeconflictresolutionswhenrebasingare"sifted"intothecommitsthatcausedthem,makingtheminvisible).

    Sincethisguideisaimedatnewgitusers,youshouldbelearninghowtomerge.

    Firstmergeyourlocalrepositorywiththeremote:

    $gitcheckoutmaster$gitpull

    Thisresultsin:

    ABCDmaster\ab1234_sequences

    Thenmergeyour1234_sequencesbranchfrom1234_sequences:

    $gitcheckout1234_sequences$gitmergemaster

    Ifthelastcommandtellsyouthatconflictsmustbesolvedforafewindicatedfiles.

    Ifthat'sthecasethenthemarks>>>andand

  • Sotheresultwillbelikethat(automaticmergingc):

    ABCDmaster\\abM1234_sequences

    Note:mergingisrecommendedoverrebasing.

    Thefinalaim,thatwewanttoobtainis:

    ABCDmaster\ab1234_sequences

    Thewaytodoitisfirstofalltomergelocalrepositorywiththeremotesympy/sympy:

    $gitcheckoutmaster$gitpull

    Soweobtain:

    ABCDmaster\ab1234_sequences

    Then:

    $gitcheckout1234_sequences$gitrebasemaster

    Notethatthislastonewillrequireyoutofixsomemergeconflictsiftherearechangestothesamefileinmasterand1234_sequences.Openthefilethatittellsyouiswrong,fixthecodewith>>>and

  • 925d88fxsequencesbaseimplementation.

    Thenrunrebasecommandininteractivemode:

    $gitrebaseinteractive925d88fx

    Oryoucanuseotherwaystopointtocommits,e.g.`gitrebaseinteractiveHEAD^^`or`gitrebaseinteractiveHEAD~2`.

    Aneweditorwindowwillappear(notethatorderisreversedwithrespecttothegitlogcommand):

    pick4d6137bsomeadditionalcorrections.pick7bbbc06bugsfixing

    #Rebase925d88f..7bbbc06onto925d88f##Commands:#p,pick=usecommit#r,reword=usecommit,buteditthecommitmessage#e,edit=usecommit,butstopforamending#s,squash=usecommit,butmeldintopreviouscommit#f,fixup=like"squash",butdiscardthiscommit'slogmessage

    Toeditacommitmessage,changepicktoreword(oronoldversionsofgit,toedit)forthosethatyouwanttoeditandsavethatfile.

    Tosquashtwocommitstogether,changepicktosquash.Toremoveacommit,justdeletethelinewiththecommit.

    Toeditacommit,changepicktoedit.

    Afterthat,gitwilldropyoubackintoyoureditorforeverycommityouwanttoreword,andintotheshellforeverycommityouwantedtoedit:

    $(Changethecommitinanywayyoulike.)$gitcommitamendm"yournewmessage"$gitrebasecontinue

    Forcommitsthatyouwanttoedit,itwillstop.Youcanthendo:

    $gitresetmixedHEAD^

    Thiswill"uncommit"allthechangesfromthecommit.Youcanthenrecommitthemhoweveryouwant.Whenyouaredone,remembertodo:

    $gitrebasecontinue

    Mostofthissequencewillbeexplainedtoyoubytheoutputofthevariouscommandsofgit.Continueuntilitsays:

    Successfullyrebasedandupdatedrefs/heads/master.

    Ifatanypointyouwanttoaborttherebase,do:

    $gitrebaseabort

    Warning:thiswillrungitresethard,deletinganyuncommittedchangesyouhave.Ifyouwanttosaveyouruncommittedchanges,rungitstashfirst,andthenrungitstashpopwhenyouaredone.

  • Coding'sonlyhalfthebattleinsoftwaredevelopment:ourcodealsohastobethoroughlyreviewedbeforerelease.Reviewersthusareanintegralpartofthedevelopmentprocess.Notethatyoudonothavetohaveanyspecialpullorotherprivilegestoreviewpatches:anyonewithPythononhis/hercomputercanreview.

    Pullrequests(thepreferredavenueforpatches)forsympyarelocatedhere.Feelfreetoviewanyopenpullrequest.EachcontainsaDiscussionsectionforcomments,Commitssectionforviewingtheauthor'scommitfilesanddocumentation,andDiffsectionforviewingallthechangesincode.Tobrowsetherawcodefilesforacommit,selectacommitintheCommitssectionandclickonthe"Viewfile"linktoviewafile.

    Basedonyourlevelofexpertise,therearetwowaystoparticipateinthereviewprocess:manuallyrunningtestsandusingsympybot.Whicheveroptionyouchoose,youshouldalsomakesurethatthecommittedcodecomplieswiththeWritingdocumentationguidelines.

    IntheDiscussionsection,youcanaddacommentattheendofthelist,oryoucanclickonindividuallinesofcodeandaddacommentthere.Notethatlinecommentstendtobecomeinvisibleasamendmentstothepullrequestchangeorremovethelines.Thecommentsarenotlost,justamouseclickaway,butwillnotbereadilyvisibleanymore.

    Whendiscussingpatches,bepoliteandsticktothepointofthepatch.GitHubhaspublishedanexcellentsetofguidelinesforpullrequestsitisrecommendedreadingforreviewersaswellascoders.

    Ifyouprefertotestcodemanually,youwillfirsthavetosetupyourenvironmentasdescribedintheWorkflowprocesssection.Then,youneedtoobtainthepatchedfiles.Ifyou'rereviewingapullrequest,youshouldgettherequestedbranchintoyoursympyfolder.Gointoyourfolderandexecute(beingtheusernameofthepullrequesterandbeingthegitbranchofthepullrequest):

    $gitremoteaddgit://github.com//sympy.git$gitfetch$gitcheckoutb/

    Afterobtainingthepullrequestorpatch,gotoyoursympyrootdirectoryandexecute:

    $./bin/test$./bin/doctest

    Ifthereareanyproblems,notifytheauthorinthepullrequestbycommenting.

    Agoodoptionforbothnewandveterancodereviewersisthesympybotprogram,whichautomaticallytestscodeinpullrequestsandpoststheresultsintheappropriatepullrequests.Torunsympybot,downloadthearchiveanddecompressit.Gointothefolderandexecute:

    $./sympybotlist

    ThiswilllistallopenpullrequestsonGitHub.Toreviewapullrequestandrunalltests,execute:

    $./sympybotreview

    Reviewingpatches

    Manualtesting

    Sympybot

  • Alternatively,toreviewallopenpullrequests,execute:

    $./sympybotreviewall

    ThereviewcommandwillposttheresultsofalltestedpullrequestsintheappropriateGithubpage.Formoreinformationonsympybot,visitthereadme.

    Apullrequestorpatchmustmeetthefollowingrequirementsduringreviewbeforebeingconsideredasreadyforrelease.

    Alltestsmustpass.Rationale:Weneedtomakesurewe'renotreleasingbuggycode.Ifnewfeaturesarebeingimplementedand/orbugfixesareadded,testsshouldbeaddedforthemaswell.

    Thereviews(atleast1)mustallbepositive.Rationale:We'dlikeeveryonetoagreeonthemeritsofthepatch.Ifthereareconflictingopinions,thereviewersshouldreachaconsensus.

    Thepatchmusthavebeenpostedforatleast24hours.Rationale:Thisgivesachanceforeveryonetolookatthepatch.

    ThispageisbaseduponpresentSymPypages[26],GitHubhelp[89],[1112]andinspiredbySageguide[10]:

    [1] http://lkml.org/lkml/2000/8/25/132

    [2] http://docs.sympy.org/dev/sympypatchestutorial.html#quickstart

    [3] http://sympy.org/development.html

    [4] https://github.com/sympy/sympy/wiki

    [5] https://github.com/sympy/sympy/wiki/Pushingpatches

    [6] https://github.com/sympy/sympy/wiki/Gettingthebleedingedge

    [7] https://github.com/sympy/sympy/wiki/Githgrosettastone

    [8] http://help.github.com/pullrequests/

    [9] http://help.github.com/forkarepo/

    [10] http://sagemath.org/doc/developer/

    [11] (1,2)http://help.github.com/linuxsetupgit/

    [12] http://help.github.com/troubleshootingssh/

    Requirementsforinclusion

    References