Code Share--SVN Branch Merge (Development Branch merged into trunk)

Source: Internet
Author: User

Design logic
    1. The command line allows you to dynamically merge code from different repositories by passing values .
    2. determine if the code has been moved out to the local, if no need to move out first;
    3. get the version number of the trunk and the branch to facilitate future merging;
    4. if the trunk version number is greater than or equal to the branch version number, no merging is required;
    5. after merging, the skeleton version number is submitted to the trunk;
    6. Pull the trunk update log to see if the merge was successful;
Code logic
#!/bin/shif [-N $];then    repos_name=$1    repos_url= ' svn://domain.com/' $repos _name    repos_dir= '/root/svn _co_code/' $repos _name    if [!-D $repos _dir];then        cd/root/svn_co_code        SVN co $repos _url    fi    trunk= $repos _url '/trunk '    dev= $repos _url '/branches/dev '    trunk_ver=$ (svn info ${trunk}-rhead | grep "Last modified version:" | Cut-d '-f2)    dev_ver=$ (svn info ${dev}-rhead | grep "Last modified version:" | Cut-d '-f2)    Echo ' Trunk Branch version number (trunk): ' $trunk _ver    Echo ' Development Branch version number (Branches/dev): ' $dev _ver    if [$trunk _ver- GE $dev _ver];then        echo ' No need to merge '        exit    fi    cd $repos _dir    pwd    svn up    cd $repos _dir '/ Trunk '    svn merge-r $trunk _ver: $dev _ver $dev    svn ci-m "merge br [email protected]${dev_ver} to trunk"    pwd< C24/>SVN log |more-2    qelse    echo ' Please enter repository name '    Exitfi
Sample Example

Trunk: is the trunk branch. The production environment runs the code under this branch.

Branches/dev: Is the development branch. The developer code is mainly here.

The tester will occasionally merge the Code of the Development Branch into the trunk branch for testing.

Assume:

Repository address is: SVN://CODE.DOMAIN.COM/API

The local eviction code directory is stored in the following path:/root/svn_co_code/api

Can be executed directly under the command line

Sh./merge.sh API

To complete the automated merge

#!/bin/shif [-N $];then    repos_name=$1    repos_url= ' svn://domain.com/' $repos _name    repos_dir= '/root/svn _co_code/' $repos _name    if [!-D $repos _dir];then        cd/root/svn_co_code        SVN co $repos _url    fi    trunk= $repos _url '/trunk '    dev= $repos _url '/branches/dev '    trunk_ver=$ (svn info ${trunk}-rhead | grep "Last modified version:" | Cut-d '-f2)    dev_ver=$ (svn info ${dev}-rhead | grep "Last modified version:" | Cut-d '-f2)    Echo ' Trunk Branch version number (trunk): ' $trunk _ver    Echo ' Development Branch version number (Branches/dev): ' $dev _ver    if [$trunk _ver- GE $dev _ver];then        echo ' No need to merge '        exit    fi    cd $repos _dir    pwd    svn up    cd $repos _dir '/ Trunk '    svn merge-r $trunk _ver: $dev _ver $dev    svn ci-m "merge br [email protected]${dev_ver} to trunk"    pwd< C24/>SVN log |more-2    qelse    echo ' Please enter repository name '    Exitfi

Code Share--SVN Branch Merge (Development Branch merged into trunk)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.