Changeset View
Changeset View
Standalone View
Standalone View
cli/diff-changelog.php
Show All 20 Lines | |||||
// load Arcanist stuff | // load Arcanist stuff | ||||
require ARCANIST_INIT; | require ARCANIST_INIT; | ||||
// repository pathname | // repository pathname | ||||
if( !defined( 'REPO_PATH' ) ) { | if( !defined( 'REPO_PATH' ) ) { | ||||
define( 'REPO_PATH', __DIR__ . '/..' ); | define( 'REPO_PATH', __DIR__ . '/..' ); | ||||
} | } | ||||
// Phabricator custom Maniphest field | |||||
// https://gitpull.it/config/edit/maniphest.custom-field-definitions/ | |||||
// | |||||
// the '%s' will be replaced with a Fastlane-compatible language | |||||
// https://docs.fastlane.tools/actions/deliver/ | |||||
if( !defined( 'PHABRICATOR_MANIPHEST_CUSTOM_FIELD_CHANGELOG' ) ) { | |||||
define( 'PHABRICATOR_MANIPHEST_CUSTOM_FIELD_CHANGELOG', 'custom.changelog.%s' ); | |||||
} | |||||
// load gradle stuff | // load gradle stuff | ||||
$gradle_content = file_get_contents( REPO_PATH . '/build.gradle' ); | $gradle_content = file_get_contents( REPO_PATH . '/build.gradle' ); | ||||
preg_match( '/versionCode +([0-9]+)/', $gradle_content, $matches ); | preg_match( '/versionCode +([0-9]+)/', $gradle_content, $matches ); | ||||
$version_code = $matches[1] ?? null; | $version_code = $matches[1] ?? null; | ||||
// no code no party | // no code no party | ||||
if( !$version_code ) { | if( !$version_code ) { | ||||
throw new Exception( "unable to extract version code" ); | throw new Exception( "unable to extract version code" ); | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | foreach( $users_result['data'] as $user_data ) { | ||||
$USERS_BY_PHID[ $phid_user ] = $user_data; | $USERS_BY_PHID[ $phid_user ] = $user_data; | ||||
} | } | ||||
// for each language | // for each language | ||||
foreach( $I18N as $lang => $msg ) { | foreach( $I18N as $lang => $msg ) { | ||||
$changelog_blocks = []; | $changelog_blocks = []; | ||||
// NOTE: Phabricator has custom fields that can be populated to retrieve the changelog | |||||
// in the specified language | |||||
$phab_maniphest_custom_field_changelog = sprintf( | |||||
PHABRICATOR_MANIPHEST_CUSTOM_FIELD_CHANGELOG, | |||||
$lang | |||||
); | |||||
// for each Task | // for each Task | ||||
foreach( $tasks as $task ) { | foreach( $tasks as $task ) { | ||||
$task_id = $task['id']; | $task_id = $task['id']; | ||||
$task_name = $task['fields']['name']; | $task_name = $task['fields']['name']; | ||||
$task_descr = $task['fields']['description']; | $task_descr = $task['fields']['description']; | ||||
$phid_task_author = $task['fields']['authorPHID']; | $phid_task_author = $task['fields']['authorPHID']; | ||||
$phid_task_owner = $task['fields']['ownerPHID']; | $phid_task_owner = $task['fields']['ownerPHID']; | ||||
$author = $USERS_BY_PHID[ $phid_task_author ]; | $author = $USERS_BY_PHID[ $phid_task_author ]; | ||||
$owner = $USERS_BY_PHID[ $phid_task_owner ]; | $owner = $USERS_BY_PHID[ $phid_task_owner ]; | ||||
$username_author = $author['fields']['username']; | $username_author = $author['fields']['username']; | ||||
$username_owner = $owner ['fields']['username']; | $username_owner = $owner ['fields']['username']; | ||||
$realname_author = $author['fields']['realName'] ?? null; | $realname_author = $author['fields']['realName'] ?? null; | ||||
$realname_owner = $owner ['fields']['realName'] ?? null; | $realname_owner = $owner ['fields']['realName'] ?? null; | ||||
$task_url = PHABRICATOR_HOME . "T{$task_id}"; | $task_url = PHABRICATOR_HOME . "T{$task_id}"; | ||||
$url_author = PHABRICATOR_HOME . 'p/' . $username_author; | $url_author = PHABRICATOR_HOME . 'p/' . $username_author; | ||||
$url_owner = PHABRICATOR_HOME . 'p/' . $username_owner; | $url_owner = PHABRICATOR_HOME . 'p/' . $username_owner; | ||||
// get the most appropriate changelog field or the Task name | |||||
$changelog_title = $task['fields'][$phab_maniphest_custom_field_changelog] | |||||
?? $task_name; | |||||
// just try to show something useful for a F-Droid changelog | // just try to show something useful for a F-Droid changelog | ||||
$changelog_lines = []; | $changelog_lines = []; | ||||
// Task name and URL | // Task name and URL | ||||
$changelog_lines[] = $task_name; | $changelog_lines[] = $task_name; | ||||
// reporter by (author) | // reporter by (author) | ||||
$changelog_lines[] = sprintf( $msg['reportedByName'], $username_author ); | $changelog_lines[] = sprintf( $msg['reportedByName'], $username_author ); | ||||
Show All 19 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register