Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 152 lines (127 sloc) 3.136 kb
1a47168 Andrew Eddie Added command line application to automatically generate the changelog f...
eddieajau authored
1 #!/usr/bin/php
2 <?php
3 /**
4 * @package Joomla.Build
5 *
6 * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 // We are a valid Joomla entry point.
11 define('_JEXEC', 1);
12
13 // Setup the path related constants.
14 define('JPATH_BASE', dirname(__FILE__));
15
16 // Bootstrap the application.
17 require '../libraries/import.php';
18
19 jimport('joomla.application.cli');
20
21 /**
22 * The command line application.
23 *
24 * @package NewLifeInIT
25 * @subpackage cron
26 */
27 class Changelog extends JCli
28 {
29 /**
30 * Execute the application.
31 *
32 * @return void
33 *
34 * @since 11.3
35 */
36 public function execute()
37 {
38 // Import dependancies.
39 jimport('joomla.client.http');
40
41 try
42 {
43 $doc = new XMLWriter;
44 $doc->openMemory();
45 $doc->setIndent(true);
46 $doc->setIndentString("\t");
47 $doc->startDocument('1.0', 'utf-8');
48 $doc->startElement('appendix');
49 $doc->startElement('section');
50
51 $cutoff = 10;
52 $page = 1;
53
54 while ($cutoff--)
55 {
56 $pulls = $this->getPulls($page++);
57
58 // Check if we've gone past the last page.
59 if (empty($pulls))
60 {
61 // No more data.
62 break;
63 }
64
65 // Loop through each pull.
66 foreach ($pulls as $pull)
67 {
68 // Check if the pull has been merged.
69 if (empty($pull->pull_request->html_url))
70 {
71 // This pull has not been merged yet.
72 continue;
73 }
74
75 $doc->startElement('itemizedlist');
76 $doc->startElement('listitem');
77
78 $doc->startElement('para');
79
80 // Prepare the link to the pull.
81 $doc->text('[');
82 $doc->startElement('ulink');
83 $doc->writeAttribute('url', $pull->url);
84 $doc->writeAttribute('title', 'Closed '.$pull->closed_at);
85 $doc->text('#'.$pull->number);
86 $doc->endElement(); // ulink
87 $doc->text('] '.$pull->title.' (');
88
89 // Prepare the link to the author.
90 $doc->startElement('ulink');
91 $doc->writeAttribute('url', $pull->user->url);
92 $doc->text($pull->user->login);
93 $doc->endElement(); // ulink
94 $doc->text(')');
95
96 $doc->endElement(); // para
97
98 if (trim($pull->body))
99 {
100 $doc->startElement('para');
101 $doc->text($pull->body);
102 $doc->endElement(); // para
103 }
104
105 $doc->endElement(); // listitem
106 $doc->endElement(); // itemizedlist
107 }
108 }
109
110 $doc->endElement(); // section
111 $doc->endElement(); // appendix
112
113 // Write the file.
114 if (!is_dir('./docs'))
115 {
116 mkdir('./docs');
117 }
118
119 file_put_contents('./docs/changelog.xml', $doc->outputMemory());
120 }
121 catch (Exception $e)
122 {
123 $this->out($e->getMessage());
124 $this->close($e->getCode());
125 }
126
127 // Close normally.
128 $this->close();
129 }
130
131 /**
132 * Get a page of pull data.
133 *
134 * @param integer The page number.
135 *
136 * @return array
137 *
138 * @since 11.3
139 */
140 protected function getPulls($page)
141 {
142 $http = new JHttp;
143 $r = $http->get(
144 'https://api.github.com/repos/joomla/joomla-platform/issues?state=closed&sort=updated&direction=desc&page='.$page.'&per_page=100'
145 );
146
147 return json_decode($r->body);
148 }
149 }
150
151 JCli::getInstance('Changelog')->execute();
Something went wrong with that request. Please try again.