77function getReposVersion ()
88{
99 $ gitDir = FLUX_ROOT .'/.git ' ;
10- $ svnDir = FLUX_ROOT .'/.svn ' ;
11-
12- if (is_dir ($ gitDir )) {
10+
11+ if (is_dir ($ gitDir )) {
1312 return git_hash ();
14- }
15- else if (is_dir ($ svnDir )) {
16- return svn_version ();
13+ } else {
14+ return null ;
1715 }
1816}
1917
@@ -23,63 +21,17 @@ function getReposVersion()
2321 * @param string file name.
2422 * @return int GIT hash
2523 */
26- function git_hash ()
27- {
24+ function git_hash () {
2825 $ file = FLUX_ROOT .'/.git/refs/heads/master ' ;
29-
3026 if (file_exists ($ file ) && is_readable ($ file )) {
3127 $ lines = implode ('' , file ($ file , FILE_IGNORE_NEW_LINES |FILE_SKIP_EMPTY_LINES ));
32-
3328 if (isset ($ lines )) {
3429 return trim (substr ($ lines , 0 , 10 ));
3530 }
3631 return null ;
32+ } else {
33+ return null ;
3734 }
3835}
3936
40- /**
41- * Get the SVN revision of a directory.
42- *
43- * @param string `entries' file name.
44- * @return int Revision number
45- */
46- function svn_version ()
47- {
48- $ rev = null ;
49-
50- // Subversion 1.6 and lower
51- $ file = FLUX_ROOT .'/.svn/entries ' ;
52- if (file_exists ($ file ) && is_readable ($ file )) {
53- $ fp = fopen ($ file , 'r ' );
54- $ arr = explode ("\n" , fread ($ fp , 256 ));
55-
56- if (isset ($ arr [3 ]) && ctype_digit ($ found = trim ($ arr [3 ]))) {
57- $ rev = $ found ;
58- }
59- fclose ($ fp );
60- }
61-
62- //Subversion 1.7 and up
63- if (!isset ($ rev )) {
64- $ file = FLUX_ROOT .'/.svn/wc.db ' ;
65- $ curr = 0 ;
66-
67- if (file_exists ($ file ) && is_readable ($ file )) {
68- $ fp = fopen ($ file , 'r ' );
69-
70- while (($ line = fread ($ fp , 64 ))) {
71- if (strstr ($ line ,"!svn/ver/ " ) && sscanf (strstr ($ line ,"!svn/ver/ " ),"!svn/ver/%d/%*s " , $ curr ) == 1 ) {
72- if ($ curr > $ rev ) {
73- $ rev = $ curr ;
74- }
75- }
76- }
77-
78- fclose ($ fp );
79- }
80- }
81-
82- return $ rev ;
83- }
84-
8537?>
0 commit comments