/[web]/www/trunk/rev.php
ViewVC logotype

Contents of /www/trunk/rev.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 781 - (show annotations) (download)
Thu Jul 7 21:40:07 2011 UTC (12 years, 9 months ago) by rda
File size: 1569 byte(s)
svn report script for continuous integration prototype
1 <?php
2 /**
3 * Place this at the public root of your system and adapt $app_root
4 * so it relates to the app branch root.
5 *
6 * Used for a continuous integration prototype, on various hosts.
7 *
8 * PHP version 5
9 *
10 * @license BSD-2-Clause
11 * @author Romain d'Alverny <rda at mageia.org>
12 */
13
14 $app_root = __DIR__;
15
16 $vars = array(
17 'app' => $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'],
18 'svn' => get_svn_info($app_root),
19 'status' => get_status($app_root),
20 );
21
22 header('Content-Type: application/json; charset=utf-8');
23 echo json_encode($vars);
24
25 //---
26
27 /**
28 * TODO Return app status (tests, config, other?)
29 *
30 * @param string $app_root
31 *
32 * @return string
33 */
34 function get_status($app_root)
35 {
36 return 'OK';
37 }
38
39 /**
40 * Return basic Subversion status info. See $keys array.
41 *
42 * @param string $app_root
43 *
44 * @return array
45 */
46 function get_svn_info($app_root)
47 {
48 exec(escapeshellcmd(sprintf('LC_ALL=C %s info %s', exec('which svn'), escapeshellarg($app_root))),
49 $out, $ret);
50
51 $vars = array();
52 $keys = array(
53 'URL',
54 'Revision',
55 'Last Changed Author',
56 'Last Changed Rev',
57 'Last Changed Date'
58 );
59 foreach ($out as $l) {
60 $l = explode(':', trim($l));
61 $k = trim(array_shift($l));
62 if (in_array($k, $keys))
63 $vars[strtolower(str_replace(' ', '_', $k))] = trim(implode(':', $l));
64 }
65
66 // remove scheme & user; keep it?
67 $u = $vars['url'];
68 $u = parse_url($u);
69 $vars['url'] = sprintf('%s%s', $u['host'], $u['path']);
70
71 return $vars;
72 }

Properties

Name Value
svn:keywords Id,Author,Date,Rev

  ViewVC Help
Powered by ViewVC 1.1.30