Skip to content

fix on api_version all usage #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions fserver.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
function fserver_drush_command() {
$items = array();
$items['fserver-status'] = array(
'callback' => 'fserver_drush_status',
'description' => 'Determine the packaging status of a project.',
);
$items['fserver-package'] = array(
'callback' => 'fserver_drush_package',
'description' => 'Update packaging for a project.',
);
$items['fserver-distro'] = array(
'callback' => 'fserver_drush_distro',
'description' => 'Update packaging for a distribution.',
);
return $items;
Expand All @@ -53,7 +50,7 @@ function fserver_drush_help($section) {
/**
* Package new releases for a specified project or all.
*/
function fserver_drush_package() {
function drush_fserver_package() {
if (!drush_get_option('uri') && !drush_get_option('l')) {
drush_die('You must use the --uri option to specify the location of this site.');
}
Expand Down Expand Up @@ -94,7 +91,7 @@ function fserver_drush_package() {
/**
* Display project packaging status.
*/
function fserver_drush_status() {
function drush_fserver_status() {
$projects = _fserver_drush_get_projects();

// Filter the project list by the argument.
Expand Down Expand Up @@ -276,7 +273,7 @@ class FserverProject {
$packaging[] = "version = \"{$tag['version']}\"";
$packaging = "\n" . implode("\n", $packaging);

$files = file_scan_directory($this->backend->path, '.info', $exclude_mask);
$files = file_scan_directory($this->backend->path, '.info$', $exclude_mask);
foreach ($files as $path => $file) {
// @TODO: Parse the info file or not?
$info_file = file_get_contents($file->filename);
Expand Down Expand Up @@ -348,23 +345,15 @@ class FserverProject_git {
$this->init_wc();

// Retrieve tag info
_drush_shell_exec_output_set(' '); // Clear output cache.
drush_op('drush_shell_exec', "git --git-dir={$this->path}/.git show {$vc}");
_drush_shell_exec_output_set(' '); // Clear output cache.
drush_op('drush_shell_exec', "git --git-dir={$this->path}/.git log -1 --pretty=format:%%ct {$vc}");
$info = drush_shell_exec_output();
if ($info[0] == "tag {$vc}") {
$info = implode("\n", $info);
$info = explode("\n\n", $info);
list($basic, $commit, $message) = $info;

$basic = explode("\n", $basic);
array_shift($basic); // Removes tag line
array_shift($basic); // Removes author line

// Set timestamp on the tag
$date = array_shift($basic);
$date = strtotime(trim(substr($date, strpos($date, ':') + 1)));
$tag['timestamp'] = is_numeric($date) ? $date : time();
}
$tag['timestamp'] = $info[0];
drush_op('drush_shell_exec', "git --git-dir={$this->path}/.git tag -l {$vc} -n 1000");
$info = drush_shell_exec_output();
// Remove the tag from the first line of the message:
$info[0] = str_replace($vc, '', $info[0]);
$tag['message'] = implode("\n", $info);
return $tag;
}
}
Expand All @@ -381,7 +370,7 @@ class FserverProject_git {
// Create the directory if it doesn't exist.
if (file_check_directory($file_path, TRUE)) {
$vc = $tag['original'];
drush_op('drush_shell_exec', "git --git-dir={$this->path}/.git checkout {$vc}");
drush_op('drush_shell_exec', "git --git-dir={$this->path}/.git --work-tree={$this->path} checkout {$vc}");
$this->FserverProject->write_package_info($tag, array('.git'));
drush_op('drush_shell_exec', "tar -Pcf - --exclude='.git' --transform='s,{$this->path},{$this->FserverProject->name},' {$this->path} | gzip > {$file_path}/{$base}.tgz");

Expand Down Expand Up @@ -564,7 +553,7 @@ function fserver_posix_groupname() {
return NULL;
}

function fserver_drush_distro() {
function drush_fserver_distro() {
if (!drush_get_option('version')) {
drush_die('No version supplied, please use --version to specify a version for your release.');
}
Expand Down
2 changes: 1 addition & 1 deletion fserver.info
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ features[views][] = "fserver_projects"
features[views][] = "fserver_release_lookup"
features[views][] = "fserver_releases"
features[views][] = "fserver_updates"
features[views_api][] = "api:3.0-alpha1"
features[views_api][] = "api:2"
name = "Feature Server"
package = "Features"
30 changes: 17 additions & 13 deletions fserver.module
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,32 @@ function fserver_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
function fserver_cck_options($type = 'core') {
switch ($type) {
case 'core':
return drupal_map_assoc(array('5.x', '6.x', '7.x'));

$result = drupal_map_assoc(array('5.x', '6.x', '7.x'));
break;
case 'major':
$major = range(0, 50);
unset($major[0]);
return $major;

$result = $major;
break;
case 'method':
return array(
$result = array(
0 => t('Manual upload'),
'git' => t('GIT repository tags'),
'svn' => t('SVN repository tags folder'),
);

break;
case 'patch':
return range(0, 50);

$result = range(0, 50);
break;
case 'recommended':
return array(t('Not recommended'), t('Recommended'));

$result = array(t('Not recommended'), t('Recommended'));
break;
case 'security':
return array(t('Not a security release'), t('Security release'));

$result = array(t('Not a security release'), t('Security release'));
break;
case 'type':
// We don't use t() here as the update XML requires these strings to be uniform.
return array(
$result = array(
// 'core' => 'Drupal project',
'profile' => 'Installation profiles',
'module' => 'Modules',
Expand All @@ -131,6 +131,10 @@ function fserver_cck_options($type = 'core') {
// 'translation' => 'Translations',
);
}

drupal_alter('fserver_cck_options', $result, $type);

return $result;
}

/**
Expand Down
81 changes: 81 additions & 0 deletions fserver.views_default.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function fserver_views_default_views() {
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));

$views[$view->name] = $view;
Expand Down Expand Up @@ -895,6 +896,7 @@ function fserver_views_default_views() {
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));

$views[$view->name] = $view;
Expand Down Expand Up @@ -1418,6 +1420,82 @@ function fserver_views_default_views() {
'field' => 'field_fserver_redirect_value',
'relationship' => 'field_fserver_project_nid',
),
'field_fserver_method_value' => array(
'label' => 'Packaging method',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'widget',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_fserver_method_value',
'table' => 'node_data_field_fserver_method',
'field' => 'field_fserver_method_value',
'relationship' => 'field_fserver_project_nid',
),
'field_fserver_repository_value' => array(
'label' => 'Repository URL',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'widget',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_fserver_repository_value',
'table' => 'node_data_field_fserver_repository',
'field' => 'field_fserver_repository_value',
'relationship' => 'field_fserver_project_nid',
),
));
$handler->override_option('sorts', array(
'release_tag' => array(
Expand Down Expand Up @@ -1576,6 +1654,8 @@ function fserver_views_default_views() {
'link' => 'nid',
'type' => 'field_fserver_type_value',
'redirect' => 'field_fserver_redirect_value',
'sourcecode_type' => 'field_fserver_method_value',
'sourcecode_uri' => 'field_fserver_repository_value',
),
'release' => array(
'version_major' => 'field_fserver_versionmajor_value',
Expand Down Expand Up @@ -1604,6 +1684,7 @@ function fserver_views_default_views() {
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('displays', array());
$handler->override_option('sitename_title', FALSE);
Expand Down
16 changes: 4 additions & 12 deletions views/fserver-updatexml.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,30 @@
<title><?php print $project['title'] ?></title>
<short_name><?php print $project['short_name'] ?></short_name>
<api_version><?php print $project['api_version'] ?></api_version>

<recommended_major><?php print $project['recommended_major'] ?></recommended_major>
<supported_majors><?php print $project['supported_majors'] ?></supported_majors>
<default_major><?php print $project['recommended_major'] ?></default_major>

<project_status>1</project_status>

<link><?php print $project['link'] ?></link>

<terms>
<term>
<name>Projects</name>
<value><?php print $project['type'] ?></value>
</term>
</terms>

<sourcecode>
<type><?php print $project['sourcecode_type']; ?></type>
<uri><?php print $project['sourcecode_uri']; ?></uri>
</sourcecode>
<releases>
<?php foreach ($releases as $release): ?>

<release>

<name><?php print $release['name'] ?></name>
<version><?php print $release['version'] ?></version>

<version_major><?php print $release['version_major'] ?></version_major>
<version_patch><?php print $release['version_patch'] ?></version_patch>
<?php if (!empty($release['version_extra'])): ?><version_extra><?php print $release['version_extra'] ?></version_extra><?php endif; ?>

<status>published</status>

<release_link><?php print $release['release_link'] ?></release_link>
<download_link><?php print $release['download_link'] ?></download_link>
<date><?php print $release['date'] ?></date>
Expand All @@ -46,10 +40,8 @@
<value>Security update</value>
</term>
</terms><?php endif; ?>

</release>
<?php endforeach; ?>

</releases>
</project>
<?php else: ?>
Expand Down
26 changes: 23 additions & 3 deletions views/fserver_plugin_style_updatexml.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class fserver_plugin_style_updatexml extends views_plugin_style {
* List of project XML elements.
*/
private function project_elements() {
return array('title', 'short_name', 'api_version', 'link', 'type', 'redirect');
return array('title', 'short_name', 'api_version', 'link', 'type', 'redirect', 'sourcecode_type', 'sourcecode_uri');
}

/**
Expand Down Expand Up @@ -95,6 +95,8 @@ class fserver_plugin_style_updatexml extends views_plugin_style {
}
}
}
// @TODO: need to correct the api version in project tag, if we have multiple api versions
// we need the key "all" instead of 5.x / 6.x / 7.x /...

// If this is a legacy project and has a redirect URL use it immediately.
if (!empty($project['redirect'])) {
Expand All @@ -112,6 +114,10 @@ class fserver_plugin_style_updatexml extends views_plugin_style {
$releases = array();
$project['recommended_major'] = '';
$project['supported_majors'] = array();

// Helper array for detecting multiple API Versions... (not the best way?)
$multiple_api_versions = array();

foreach ($vars['rows'] as $num => $row) {
foreach ($vars['options']['release'] as $element => $field) {
$alias = $fields[$field]->field_alias;
Expand All @@ -131,7 +137,15 @@ class fserver_plugin_style_updatexml extends views_plugin_style {
}
}
}


// manual mapping from project api field to release api field
$project_api_version_mapping = $fields[$vars['options']['project']['api_version']]->field_alias;
if(isset($row->{$project_api_version_mapping})) {
$releases[$num]['api_version'] = $fields[$vars['options']['project']['api_version']]->theme($row);
// add current version to helper array...
$multiple_api_versions[$releases[$num]['api_version']] = $releases[$num]['api_version'];
}

if ($releases[$num]['recommended']) {
// Use the first major version for the project major.
// The list is sorted by "major desc", this way the latest branch will be
Expand All @@ -144,7 +158,7 @@ class fserver_plugin_style_updatexml extends views_plugin_style {
}

// Version
$releases[$num]['version'] = "{$project['api_version']}-{$releases[$num]['version_major']}.{$releases[$num]['version_patch']}";
$releases[$num]['version'] = "{$releases[$num]['api_version']}-{$releases[$num]['version_major']}.{$releases[$num]['version_patch']}";
if (!empty($releases[$num]['version_extra'])) {
$releases[$num]['version'] .= "-{$releases[$num]['version_extra']}";
}
Expand All @@ -158,8 +172,14 @@ class fserver_plugin_style_updatexml extends views_plugin_style {
// Download link
$releases[$num]['download_link'] = file_create_url($releases[$num]['download_link']);
}

sort($project['supported_majors']);
$project['supported_majors'] = implode(",", $project['supported_majors']);

// overwrite projects api version if we have multiple versions to "all"
if (count($multiple_api_versions) > 1) {
$project['api_version'] = 'all';
}

// Finalize
$vars['project'] = $project;
Expand Down