示例#1
0
 public static function addCommit($sCommit, $sAuthor)
 {
     // Get author info seperated first
     // Bradley T. Hughes <*****@*****.**>
     $aAuthorBits = array();
     if (!preg_match("/(.+) \\<(.+)(?:@| at )([^. ]*)[ .]?.*\\>/", $sAuthor, $aAuthorBits)) {
         die("couldn't get author info for author " . $sAuthor . "\n");
     }
     // matches are:
     // string 0
     // real name 1
     // email (from bit) 2
     // email (domain bit, first word only to avoid TLD madness) 3
     //
     // first, try find the Organisation this Person belongs to
     $oOrganisation = self::findOrganisation($aAuthorBits[3]);
     if (!$oOrganisation) {
         // create one
         $oOrganisation = new Organisation();
         $oOrganisation->setName($aAuthorBits[3]);
         // add under both name and email thingy
         self::$aOrganisations[strtolower($aAuthorBits[3])] = $oOrganisation;
     }
     // let's try find a Person
     $oPerson = self::findPerson($aAuthorBits[1]);
     if (!$oPerson) {
         // try again
         $oPerson = self::findPerson($aAuthorBits[2]);
     }
     if (!$oPerson) {
         // Person record doesn't exist, let's create one
         $oPerson = new Person();
         $oPerson->setName($aAuthorBits[1]);
         $oPerson->setEmail($sAuthor);
         // add under both name and email thingy
         self::$aPersons[strtolower($aAuthorBits[1])] = $oPerson;
         self::$aPersons[strtolower($aAuthorBits[2])] = $oPerson;
     }
     // always set their organisation, as people may move from one org to
     // another and keep contributing.
     $oPerson->setOrganisation($oOrganisation);
     // simple bookkeeping first
     $oPerson->setCommitCount($oPerson->commitCount() + 1);
     $oPerson->organisation()->setCommitCount($oPerson->organisation()->commitCount() + 1);
     $oPerson->appendToCommitQueue($sCommit);
 }