Subversion Repositories oidplus

Rev

Rev 693 | Rev 699 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 693 Rev 698
Line 994... Line 994...
994
                if ($svn_dir_exists = (is_dir(OIDplus::localpath().'.svn') ||
994
                if ($svn_dir_exists = (is_dir(OIDplus::localpath().'.svn') ||
995
                                       is_dir(OIDplus::localpath().'../.svn'))) { // in case we checked out the root instead of the "trunk"
995
                                       is_dir(OIDplus::localpath().'../.svn'))) { // in case we checked out the root instead of the "trunk"
996
                        $counter++;
996
                        $counter++;
997
                }
997
                }
998
                // if ($git_dir_exists = is_dir(OIDplus::localpath().'.git')) {
998
                // if ($git_dir_exists = is_dir(OIDplus::localpath().'.git')) {
999
                if ($git_dir_exists = (find_git_folder() !== false)) {
999
                if ($git_dir_exists = (OIDplus::findGitFolder() !== false)) {
1000
                        $counter++;
1000
                        $counter++;
1001
                }
1001
                }
1002
 
1002
 
1003
                if ($counter === 0) {
1003
                if ($counter === 0) {
1004
                        return 'unknown'; // do not translate
1004
                        return 'unknown'; // do not translate
Line 1046... Line 1046...
1046
                        if ($ver)
1046
                        if ($ver)
1047
                                return ($cachedVersion = 'svn-'.$ver);
1047
                                return ($cachedVersion = 'svn-'.$ver);
1048
                }
1048
                }
1049
 
1049
 
1050
                if ($installType === 'git-wc') {
1050
                if ($installType === 'git-wc') {
1051
                        $ver = get_gitsvn_revision(OIDplus::localpath());
1051
                        $ver = OIDplus::getGitsvnRevision(OIDplus::localpath());
1052
                        if ($ver)
1052
                        if ($ver)
1053
                                return ($cachedVersion = 'svn-'.$ver);
1053
                                return ($cachedVersion = 'svn-'.$ver);
1054
                }
1054
                }
1055
 
1055
 
1056
                if ($installType === 'svn-snapshot') {
1056
                if ($installType === 'svn-snapshot') {
Line 1302... Line 1302...
1302
                        }
1302
                        }
1303
                }
1303
                }
1304
                return self::$translationArray;
1304
                return self::$translationArray;
1305
        }
1305
        }
1306
 
1306
 
-
 
1307
        public static function findGitFolder() {
-
 
1308
                // Git command line saves git information in folder ".git"
-
 
1309
                // Plesk git saves git information in folder "../../../git/oidplus/" (or similar)
-
 
1310
                $dir = realpath(__DIR__);
-
 
1311
                if (is_dir($dir.'/.git')) return $dir.'/.git';
-
 
1312
                $i = 0;
-
 
1313
                do {
-
 
1314
                        if (is_dir($dir.'/git')) {
-
 
1315
                                $confs = glob($dir.'/git/'.'*'.'/config');
-
 
1316
                                foreach ($confs as $conf) {
-
 
1317
                                        $cont = file_get_contents($conf);
-
 
1318
                                        if (strpos($cont, '://github.com/danielmarschall/oidplus') !== false) {
-
 
1319
                                                return dirname($conf);
-
 
1320
                                        }
-
 
1321
                                }
-
 
1322
                        }
-
 
1323
                        $i++;
-
 
1324
                } while (($i<100) && ($dir != ($new_dir = realpath($dir.'/../'))) && ($dir = $new_dir));
-
 
1325
                return false;
-
 
1326
        }
-
 
1327
 
-
 
1328
        public static function getGitsvnRevision($dir='') {
-
 
1329
                try {
-
 
1330
                        // tries command line and binary parsing
-
 
1331
                        // requires danielmarschall/git_utils.inc.php
-
 
1332
                        $git_dir = OIDplus::findGitFolder();
-
 
1333
                        if ($git_dir === false) return false;
-
 
1334
                        $commit_msg = git_get_latest_commit_message($git_dir);
-
 
1335
                } catch (Exception $e) {
-
 
1336
                        return false;
-
 
1337
                }
-
 
1338
 
-
 
1339
                $m = array();
-
 
1340
                if (preg_match('%git-svn-id: (.+)@(\\d+) %ismU', $commit_msg, $m)) {
-
 
1341
                        return $m[2];
-
 
1342
                } else {
-
 
1343
                        return false;
-
 
1344
                }
-
 
1345
        }
-
 
1346
 
1307
}
1347
}