<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Knight of the round table

    wansong

    codeStriker(及與svn、bugzilla集成)使用過程記錄 續

    下面是codeStriker與svn、bugzilla集成使用的腳本(放在codestriker安裝目錄的bin下):

     

    #!/usr/bin/perl -w
    #########################################################################
    # Create codestriker topic based on subversion commit.
    # Install as a post-commit subversion hook.
    # dmp 03/23/07
    #########################################################################

    # Absolute path of file mapping the author of a commit to a reviewer for it.
    # Each line of the file should contain an author email address,
    # followed by whitespace, followed by a reviewer email address.
    # Lines starting with '#' are comments.
    $REVIEWERS_FILE = "D:/hooks/reviewers.txt";

    # Reviewer email to use if no mapping found in REVIEWERS_FILE
    $DEFAULT_REVIEWER = "username\@hotmail.com";

    # Suffix to add to username to get email address.
    # TODO:  Would be better to get mappings from a file.
    $EMAIL_SUFFIX = "\@hotmail.com";

    # Codestriker specific parameters for topic creation.
    $CODESTRIKER_URL = 'http://localhost/codestriker/codestriker.pl?action=create';
    $CODESTRIKER_PROJECT = '2';
    $CODESTRIKER_REPOSITORY = 'svn:file:///D:/svnroo';
    $CODESTRIKER_CC = '';

    # Used for development - write verbosely to log file
    $DEBUG = 1;
    $LOGFILE = "D:/codestriker-1.9.8/bin/post-commit-codestriker.log";

    use lib 'D:/codestriker-1.9.8/bin';
    ########################################################################
    # Shouldn't need to change anything under here.

    # Codestriker-specific imports.
    use CodestrikerClient;

    use LWP::UserAgent;
    use HTTP::Request;
    use HTTP::Request::Common;

    # Print message to stdout if DEBUG is set.
    sub debug {
        local($msg) = @_;

        if ($DEBUG) {
            open(LOG, ">>$LOGFILE") || die ("Cannot open log file $LOGFILE: $!\n");
            print(LOG $msg, "\n");
            close(LOG);
        }
    }

    # Get the email address for the given username.  Currently this just adds
    # $EMAIL_SUFFIX to the username, but it would be better to use a mapping file.
    # param username
    # return email address
    sub get_email {
        local($username) = @_;
        return $username . $EMAIL_SUFFIX;
    }

    # Determine reviewer for review, based on mappings in
    # REVIEWERS file.
    # param:  author email address
    # returns: the reviewer email address from the file, or DEFAULT_REVIEWER
    sub determine_reviewer {
        local($author_email) = @_;
        my $reviewer = '';

        debug("author email is: " . $author_email);
        debug("attempting to open reviewers file: $REVIEWERS_FILE");
        open (RECLIST, "< $REVIEWERS_FILE") ||
            return $DEFAULT_REVIEWER;

        while (<RECLIST>) {
            # skip comment lines
            if (/^#/) {
                next;
            }

            @fields = split;
            if ($fields[0] eq $author_email) {
                $reviewer = $fields[1];
                debug("The reviewer for " . $author_email . " is: " . $reviewer);
                last;
            }
        }

        close RECLIST;

        if (! $reviewer) {
            $reviewer = $DEFAULT_REVIEWER;
            debug("Assigned default reviewer: " . $reviewer);
        }

        return $reviewer;
    }

    ########################################################################
    # Main program

    my $repo=$ARGV[0];
    my $rev=$ARGV[1];

    debug("repos=$repo; rev=$rev");

    my @svninfo_out=split("\n", `svnlook info -r $rev $repo`);
    my $user=$svninfo_out[0];
    my $date=$svninfo_out[1];
    my $loglength=$svninfo_out[2];
    my $topic_title = "SVN commit: " . $svninfo_out[3];
    my $mesg=join("\n", @svninfo_out[3..$#svninfo_out]);

    debug("user=$user");
    debug("date=$date");
    debug("loglength=$loglength");
    debug("mesg=$mesg");

    my $createTopic = 0;
    if ($mesg =~ /REVIEW/) {
        debug("Found REVIEW - creating topic.");
        $createTopic = 1;
    }

    # Look for bug numbers in the log message, which need to be in the form:
    # " Bug: 4250 " (without quotes, case insensitive, colon and space optional).
    my @bugs = ();
    my $bug_ids = $mesg;
    while ($bug_ids =~ /\b[Bb][Uu][Gg]:?\s*(\d+)\b/g) {
        push @bugs, $1;
        debug("Found bug number $1; creating topic.");
        $createTopic = 1;
    }

    if ($createTopic) {
        # Truncate the title if necessary.
        if (length($topic_title) > 57) {
            $topic_title = substr($topic_title, 0, 57) . "...";
        }

        my $reviewer = determine_reviewer(get_email($user));

        debug("Creating topic...");
        my $ua = new LWP::UserAgent;
        my $content = [ action => 'submit_new_topic',
                    topic_title => $topic_title,
                    topic_description => $mesg,
                    projectid => $CODESTRIKER_PROJECT,
                    repository => $CODESTRIKER_REPOSITORY,
                    bug_ids => join(", ", @bugs),
                    email => get_email($user),
                    reviewers => $reviewer,
                    cc => $CODESTRIKER_CC,
      topic_state => 'Open',
                    module => "/",
                    start_tag => $rev - 1,
                    end_tag => $rev];
        my $response =
            $ua->request(HTTP::Request::Common::POST($CODESTRIKER_URL,
                                 Content_Type => 'form-data',
                                 Content => $content));

        # Indicate if the operation was successful.
        my $response_content = $response->content;
        my $rc = $response_content =~ /Topic URL: \<A HREF=\"(.*)\"/i;
        print STDERR "Failed to create topic, response: " .
                        $response_content . "\n" if $rc == 0;

    } else {
        debug("Not creating topic.");
    }

    posted on 2009-04-03 10:06 w@ns0ng 閱讀(1255) 評論(0)  編輯  收藏 所屬分類: J2EE

    主站蜘蛛池模板: 久久免费动漫品精老司机| 国产乱码免费卡1卡二卡3卡| 亚洲αv在线精品糸列| 日韩免费人妻AV无码专区蜜桃| jlzzjlzz亚洲jzjzjz| 免费国产人做人视频在线观看| a级毛片高清免费视频就| 亚洲成a人片7777| 亚洲成人影院在线观看| 99视频精品全部免费观看| 亚洲精品无码高潮喷水A片软| 亚洲欧洲无码AV电影在线观看| 国产精品久久永久免费| 黄人成a动漫片免费网站| 久久精品国产亚洲AV麻豆王友容| 成人免费视频观看无遮挡| 你好老叔电影观看免费| 亚洲综合中文字幕无线码| 欧洲亚洲国产清在高| 在线观看免费宅男视频| 免费毛片在线看不用播放器 | 亚洲国产成人一区二区精品区| 成人免费观看一区二区| 国产成人无码精品久久久久免费| 亚洲中文字幕久久精品无码2021| 亚洲小说区图片区另类春色| 四色在线精品免费观看| 午夜精品免费在线观看| 免费一级毛片在线播放放视频| 91亚洲精品自在在线观看| 亚洲最大av无码网址| 在线看片人成视频免费无遮挡| 久久免费视频网站| 一区二区免费国产在线观看| 最新亚洲精品国偷自产在线| 久久久亚洲精品无码| 亚洲片一区二区三区| 韩国二级毛片免费播放| 99久久免费国产香蕉麻豆| 久艹视频在线免费观看| 一级特黄特色的免费大片视频|