Skip to content

Commit

Permalink
Merge branch 'esope_1.10' of github.com:Facyla/esope into esope_1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Facyla committed Jun 10, 2015
2 parents 70109d6 + de53d86 commit fd93022
Show file tree
Hide file tree
Showing 3,236 changed files with 228,380 additions and 139,707 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
17 changes: 17 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Aday Talavera <[email protected]>
András Szepesházi <[email protected]>
Ben Werdmuller <[email protected]> <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>
Brett Profitt <[email protected]> <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Cash Costello <[email protected]> <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Cash Costello <[email protected]>
Evan Winslow <[email protected]>
Evan Winslow <[email protected]> <[email protected]>
Evan Winslow <[email protected]> <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Ismayil Khayredinov <[email protected]> <[email protected]>
Ismayil Khayredinov <[email protected]>
Jeff Tilson <[email protected]> <[email protected]>
Jerôme Bakker <[email protected]>
Matt Beckett <[email protected]>
Marcus Povey <[email protected]> <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>
Paweł Sroka <[email protected]>
Steve Clay <[email protected]> <[email protected]>
23 changes: 23 additions & 0 deletions .scripts/fix_style.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

if (php_sapi_name() !== "cli") {
die('CLI only');
}

$root = dirname(__DIR__);
if (!is_writable($root)) {
echo "$root is not writable.\n";
exit(1);
}

require "$root/engine/classes/Elgg/Project/CodeStyle.php";

$style = new Elgg\Project\CodeStyle();

$report = $style->fixDirectory($root);
if (!$report) {
exit;
}

$json_opts = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
echo json_encode($report, $json_opts) . "\n";
57 changes: 57 additions & 0 deletions .scripts/move_namespaces_to_top.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

// for each file that has a namespace declaration
$dir = __DIR__;
$filesWithNamespaceDeclaration = explode("\n", `grep -r '^namespace' $dir --include=*.php --exclude=vendor -l`);

// echo implode("\n", $filesWithNamespaceDeclaration);

foreach ($filesWithNamespaceDeclaration as $file) {
moveNamespaceToTop($file);
}

function moveNamespaceToTop($file) {
if (!is_file($file)) {
return;
}

$contents = file_get_contents($file);
$lines = explode("\n", $contents);

$nsDeclarationPosition = findPositionOfNamespaceDeclaration($lines);

if ($nsDeclarationPosition == -1) {
return;
}

$declaration = $lines[$nsDeclarationPosition];

// echo "$declaration\n";

unset($lines[$nsDeclarationPosition]);

array_splice($lines, 1, 0, $declaration);

$newContents = implode("\n", $lines) . "\n";

file_put_contents($file, $newContents);
}

function findPositionOfNamespaceDeclaration($lines) {
$position = -1;
foreach ($lines as $pos => $lineContent) {
if (isNamespaceDeclaration($lineContent)) {
$position = $pos;
}
}

return $position;
}

function isNamespaceDeclaration($lineContent) {
return strpos($lineContent, "namespace ") === 0;
}
// get the contents of that file and split into lines
// find the line with the namespace declaration and remove it
// insert it into the second position
// write all the lines back to the file
74 changes: 74 additions & 0 deletions .scripts/release.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

if (!isset($argv[1]) || $argv[1] == '--help') {
echo "Usage: php .scripts/release.php <semver>\n";
exit;
}

$version = $argv[1];

// Verify that $version is a valid semver string
// Performing check according to: https://getcomposer.org/doc/04-schema.md#version
$regexp = '/^[0-9]+\.[0-9]+\.[0-9]+(?:-(?:dev|rc\.[0-9]+))?$/';

if (!preg_match($regexp, $version, $matches)) {
echo "Bad version format. You must follow the format of X.Y.Z with an optional suffix of -dev,"
. " or -rc.N (where N is a number).\n";
exit(1);
}

function run_commands($commands) {
foreach ($commands as $command) {
echo "$command\n";
passthru($command, $return_val);
if ($return_val !== 0) {
echo "Error executing command! Interrupting!\n";
exit(2);
}
}
}

$elgg_path = dirname(__DIR__);

$branch = "release-$version";


// Setup. Version checks are here so we fail early if any deps are missing
run_commands(array(
"tx --version",
"git --version",
"npm --version",
"node --version",
"sphinx-build --version",

"cd $elgg_path",
"git checkout -B $branch",
));


// Update translations
run_commands(array(
"tx pull -a --minimum-perc=100",
"sphinx-build -b gettext docs docs/locale/pot",
"sphinx-intl --locale-dir=docs/locale/ build",
"git add .",
"git commit -am \"chore(i18n): update translations\"",
));

// Update version in composer.json
require_once __DIR__ . '/../engine/classes/Elgg/Json/EmptyKeyEncoding.php';
$encoding = new \Elgg\Json\EmptyKeyEncoding();

$composer_path = "$elgg_path/composer.json";
$composer_config = $encoding->decode(file_get_contents($composer_path));
$composer_config->version = $version;
$json = $encoding->encode($composer_config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
file_put_contents($composer_path, $json);

// Generate changelog
run_commands(array(
"npm install && npm update",
"node .scripts/write-changelog.js",
"git add .",
"git commit -am \"chore(release): v$version\"",
));
44 changes: 44 additions & 0 deletions .scripts/travis/check_commit_msgs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Checks the commits msgs in the range of commits travis is testing.
# Based heavily on
# https://github.com/JensRantil/angular.js/blob/ffe93bb368037049820ac05ef62f8cc7ed379d98/test-commit-msgs.sh

# Travis's docs are misleading.
# Check for either a commit or a range (which apparently isn't always a range) and fix as needed.
if [ "$#" -gt 0 ]; then
RANGE=$1
elif [ "$TRAVIS_COMMIT_RANGE" != "" ]; then
RANGE=$TRAVIS_COMMIT_RANGE
elif [ "$TRAVIS_COMMIT" != "" ]; then
RANGE=$TRAVIS_COMMIT
fi


if [ "$RANGE" == "" ]; then
echo -n "RANGE is empty!"
exit 1
fi

# Travis sends the ranges with 3 dots. Git only wants 2.
if [[ "$RANGE" == *...* ]]; then
RANGE=`echo $TRAVIS_COMMIT_RANGE | sed 's/\.\.\./../'`
elif [[ "$RANGE" != *..* ]]; then
RANGE="$RANGE~..$RANGE"
fi

EXIT=0
for sha in `git log --format=oneline "$RANGE" | cut '-d ' -f1`
do
echo -n "Checking commit message for $sha ... "
git log --format=%B -n 1 $sha | php ./.scripts/validate_commit_msg.php

VALUE=$?

if [ "$VALUE" -gt 0 ]; then
echo -n "./.scripts/validate_commit_msg.php exited with error!"
EXIT=$VALUE
fi
done

exit $EXIT
151 changes: 151 additions & 0 deletions .scripts/validate_commit_msg.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/usr/bin/php
<?php
/**
* Validates the text of a commit message.
*
* Text should be passed as the only argument, the path to a file (compatibility
* with commit-msg git hook), or through stdin.
*
* Writes any errors to stdout.
* Exits with 0 on success, > = 0 on failure.
*
* Can't pass multiple msgs at once.
*
* To use as a git commit hook, make sure the PHP path is correct, then
* copy or symlink to .git/hooks/commit-msg.
*
*/

$rootDir = dirname(__DIR__);

require_once "$rootDir/vendor/autoload.php";

$is_file = false;

if ($argc === 2) {
// check file or msg itself
$arg = $argv[1];

if (file_exists($arg)) {
$is_file = true;
$msg_tmp = file_get_contents($arg);
} else {
$msg_tmp = $arg;
}
} else {
// check for std in
$msg_tmp = file_get_contents("php://stdin");
}

$msg = new Elgg\CommitMessage($msg_tmp);

if (!$msg->getMsg()) {
usage();
}

if ($msg->shouldIgnore()) {
output("Ignoring commit.", 'notice');
exit(0);
}

// basic format
// don't continue if not correct
if (!$msg->isValidFormat()) {
output("Fail.", 'error');
output("Not in the format `type(component): summary`", 'error');
output($msg, 'error');
if ($is_file) {
output("\nCommit message saved in " . $argv[1]);
}
exit(1);
}

$errors = array();

// line lengths
if (!$msg->isValidLineLength()) {
$max = $msg->getMaxLineLength();
foreach ($msg->getLengthyLines() as $line_num) {
$errors[] = "Longer than $max characters at line $line_num";
}
}

// type
if (!$msg->isValidType()) {
$errors[] = "Invalid type at line 1: `{$msg->getPart('type')}`. Not one of "
. implode(', ', $msg->getValidTypes()) . '.';
}

// component
// @todo only checking for existence right now via regex

// @todo check for fixes, refs, etc only in body and not in summary?
// @todo check for correct syntax for breaks and deprecates?
if ($errors) {
output('Fail', 'error');
foreach ($errors as $error) {
output($error, 'error');
}
$arg = escapeshellarg($msg);

$cmd = "printf '%s' $arg | nl -ba";
$output = shell_exec($cmd);
output($output, 'error', false);
if ($is_file) {
output("\nCommit message saved in " . $argv[1]);
}
exit(1);
} else {
// only if we're not in a git commit
if (!$is_file) {
output('Ok', 'success');
}
exit(0);
}


/**
* Output a msg followed by a \n
*
* @param string $msg The message to output
* @param bool $error If true, the message is in red.
*/
function output($msg, $type = 'message', $trailing_return = true) {
$colors = array(
'red' => '0;31',
'green' => '0;32',
'yellow' => '0;33'
);

$types = array(
'message' => '',
'error' => 'red',
'notice' => 'yellow',
'success' => 'green'
);

$n = $trailing_return ? "\n" : '';

switch ($type) {
case 'error':
case 'notice':
case 'success':
$color = $colors[$types[$type]];
echo "\033[{$color}m$msg\033[0m{$n}";
break;

case 'message':
default;
echo "$msg{$n}";
break;
}
}

/**
* Print usage and exit with error.
*/
function usage() {
output("Pass a commit message text or a file containing the text of a commit message as the only argument.");
exit(1);
}
22 changes: 22 additions & 0 deletions .scripts/write-changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node

var pkg = require('../composer.json');
var fs = require('fs');
var changelog = require('elgg-conventional-changelog');

changelog({
version: pkg.version,
repository: 'https://github.com/Elgg/Elgg',
types: {
feature: 'Features',
perf: 'Performance',
docs: 'Documentation',
fix: 'Bug Fixes',
deprecate: 'Deprecations',
breaks: 'Breaking Changes',
}
}, function(err, log) {
if (err) throw new Error(err);
fs.writeFileSync('CHANGELOG.md', log);
});

Loading

0 comments on commit fd93022

Please sign in to comment.