コード例 #1
0
    }
    // Check to see if this commit message references a ticket via:  [#939] OR [#939 resolved]
    // If you want to add additional commit-message functionality, you'd want to do it within this block of code...
    if (stripos($data['commit_message'], '[#') !== false) {
        // Parse out Case ID #
        $get_id = explode('[#', $data['commit_message']);
        $get_id2 = explode(']', $get_id[1]);
        $get_id3 = explode(' ', $get_id[1]);
        if (is_numeric($get_id2[0])) {
            $case_id = $get_id2[0];
        } else {
            $case_id = $get_id3[0];
        }
        // We set the 'File' that we committed as the date + _COMMITTER-NAME
        // We do this because FogBugz is designed for more traditional (CVS, SVN, etc) version control systems.  This approach leaves us with a cleaner view of changes made.  Customize as needed!
        $formatted_payload['sFile'] = date('Y-m-d_g:i:s_A') . '_' . str_replace(' ', '_', $data['committer_name']);
        $formatted_payload['sPrev'] = $data['commit_id'];
        $formatted_payload['sNew'] = $data['commit_id'];
        // We now call the 'triggerCommit' method which will add a `commit` to the proper FogBugz Case
        $fb->triggerCommit($case_id, $formatted_payload, getIDfromUsername($data['committer_name']));
        /*  Did the Commit Message contain the word 'resolved' within the brackets?  
                     If so, we're going to call the resolveCase() method which resolves the case && adds a reply to the case.  Currently, the reply will contain:
                        Resolved via Commit
                        $commit_message
                        $commit_url
            */
        if (stripos($get_id[1], 'resolved') !== false) {
            $fb->resolveCase($case_id, "Resolved via Commit\n" . $data['commit_message'] . "\n" . $data['commit_url'], getIDfromUsername($data['committer_name']));
        }
    }
}