Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
5834256e
Commit
5834256e
authored
Dec 07, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added changelog merge to release command
fixes #5975
parent
8a3d8c94
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
1 deletion
+90
-1
ReleaseController.php
build/controllers/ReleaseController.php
+90
-1
No files found.
build/controllers/ReleaseController.php
View file @
5834256e
...
...
@@ -8,6 +8,7 @@
namespace
yii\build\controllers
;
use
Yii
;
use
yii\base\Exception
;
use
yii\console\Controller
;
/**
...
...
@@ -30,6 +31,8 @@ class ReleaseController extends Controller
*/
public
function
actionPrepare
(
$version
)
{
$this
->
resortChangelogs
(
$version
);
$this
->
mergeChangelogs
(
$version
);
$this
->
closeChangelogs
(
$version
);
$this
->
composerSetStability
(
$version
);
$this
->
updateYiiVersion
(
$version
);
...
...
@@ -77,9 +80,95 @@ class ReleaseController extends Controller
}
}
protected
function
resortChangelogs
(
$version
)
{
foreach
(
$this
->
getChangelogs
()
as
$file
)
{
// split the file into relevant parts
list
(
$start
,
$changelog
,
$end
)
=
$this
->
splitChangelog
(
$file
,
$version
);
$changelog
=
$this
->
resortChangelog
(
$changelog
);
file_put_contents
(
$file
,
implode
(
"
\n
"
,
array_merge
(
$start
,
$changelog
,
$end
)));
}
}
protected
function
mergeChangelogs
(
$version
)
{
$file
=
$this
->
getFrameworkChangelog
();
// split the file into relevant parts
list
(
$start
,
$changelog
,
$end
)
=
$this
->
splitChangelog
(
$file
,
$version
);
$changelog
=
$this
->
resortChangelog
(
$changelog
);
$changelog
[]
=
''
;
$extensions
=
$this
->
getExtensionChangelogs
();
asort
(
$extensions
);
foreach
(
$extensions
as
$changelogFile
)
{
if
(
!
preg_match
(
'~extensions/([a-z]+)/CHANGELOG\\.md~'
,
$changelogFile
,
$m
))
{
throw
new
Exception
(
"Illegal extension changelog file: "
.
$changelogFile
);
}
list
(
,
$extensionChangelog
,
)
=
$this
->
splitChangelog
(
$changelogFile
,
$version
);
$name
=
$m
[
1
];
$ucname
=
ucfirst
(
$name
);
$changelog
[]
=
"###
$ucname
Extension (yii2-
$name
)"
;
$changelog
=
array_merge
(
$changelog
,
$extensionChangelog
);
}
file_put_contents
(
$file
,
implode
(
"
\n
"
,
array_merge
(
$start
,
$changelog
,
$end
)));
}
/**
* Extract changelog content for a specific version
*/
protected
function
splitChangelog
(
$file
,
$version
)
{
$lines
=
explode
(
"
\n
"
,
file_get_contents
(
$file
));
// split the file into relevant parts
$start
=
[];
$changelog
=
[];
$end
=
[];
$state
=
'start'
;
foreach
(
$lines
as
$l
=>
$line
)
{
// starting from the changelogs headline
if
(
isset
(
$lines
[
$l
-
2
])
&&
strpos
(
$lines
[
$l
-
2
],
$version
)
!==
false
&&
isset
(
$lines
[
$l
-
1
])
&&
strncmp
(
$lines
[
$l
-
1
],
'---'
,
3
)
===
0
)
{
$state
=
'changelog'
;
}
if
(
$state
===
'changelog'
&&
isset
(
$lines
[
$l
+
1
])
&&
strncmp
(
$lines
[
$l
+
1
],
'---'
,
3
)
===
0
)
{
$state
=
'end'
;
}
${$state}
[]
=
$line
;
}
return
[
$start
,
$changelog
,
$end
];
}
/**
* Ensure sorting of the changelog lines
*/
protected
function
resortChangelog
(
$changelog
)
{
// cleanup whitespace
foreach
(
$changelog
as
$i
=>
$line
)
{
$changelog
[
$i
]
=
rtrim
(
$line
);
}
// TODO sorting
return
$changelog
;
}
protected
function
getChangelogs
()
{
return
array_merge
([
YII2_PATH
.
'/CHANGELOG.md'
],
glob
(
dirname
(
YII2_PATH
)
.
'/extensions/*/CHANGELOG.md'
));
return
array_merge
([
$this
->
getFrameworkChangelog
()],
$this
->
getExtensionChangelogs
());
}
protected
function
getFrameworkChangelog
()
{
return
YII2_PATH
.
'/CHANGELOG.md'
;
}
protected
function
getExtensionChangelogs
()
{
return
glob
(
dirname
(
YII2_PATH
)
.
'/extensions/*/CHANGELOG.md'
);
}
protected
function
composerSetStability
(
$version
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment