<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

    主站蜘蛛池模板: 国产三级在线免费| 亚洲av无码专区亚洲av不卡| 美女视频黄视大全视频免费的| 最近中文字幕高清免费中文字幕mv| 亚洲另类激情专区小说图片| 亚洲综合在线一区二区三区| 免费看国产成年无码AV片| 久久青草亚洲AV无码麻豆| 黄色网页在线免费观看| 婷婷亚洲天堂影院| 国内成人精品亚洲日本语音 | 精品人妻系列无码人妻免费视频| 国内外成人免费视频| 亚洲成人免费网站| 在线观看免费av网站| 久久久久久亚洲精品| 亚洲香蕉免费有线视频| 日韩亚洲一区二区三区| 中文字幕av无码不卡免费| 亚洲午夜精品久久久久久浪潮| 看一级毛片免费观看视频| 四虎永久在线精品免费影视| 美女黄色毛片免费看| 亚洲精品tv久久久久久久久久| 偷自拍亚洲视频在线观看| 亚洲国产一区二区视频网站| 免费国产污网站在线观看不要卡| 亚洲国产精品成人一区| 国产亚洲Av综合人人澡精品| 久久久精品国产亚洲成人满18免费网站 | 亚洲熟妇av一区二区三区漫画| 免费精品一区二区三区第35 | 亚洲欧洲日本在线| 99视频免费播放| 亚洲精华国产精华精华液好用| 精品国产人成亚洲区| 美女内射毛片在线看免费人动物 | 国产亚洲精aa成人网站| 免费观看美女用震蛋喷水的视频| 亚洲人成人伊人成综合网无码| 国产成人亚洲精品91专区手机|