Skip to content

Commit

Permalink
Merge pull request #15 from CloCkWeRX/master
Browse files Browse the repository at this point in the history
Misc additions
  • Loading branch information
CloCkWeRX committed Apr 21, 2012
2 parents 4325fdb + a7ba736 commit 2bc2f49
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 0 deletions.
107 changes: 107 additions & 0 deletions admin-ci.php
@@ -0,0 +1,107 @@
<?php

/**
* Finds misplaced packages in PEAR's svn.php.net and github.com repositories
*
* @author Daniel Convissor <danielc@php.net>
*/

// Get github.com packages.
$github = array();
$github_not_pushed = array();
$result = file_get_contents('https://api.github.com/orgs/pear/repos');
$result = json_decode($result);
foreach ($result as $item) {
if ($item->pushed_at) {
$github[] = $item->name;
} else {
$github_not_pushed[] = $item->name;
}
}

// Get svn.php.net packages.
$result = `svn list https://svn.php.net/repository/pear/packages`;
$result = trim($result);
$result = str_replace('/', '', $result);
$packages = preg_split('/[\r\n]+/', $result);

// Get orphaned packages, if possible.
$orphan_packages = array();
if (!function_exists('tidy_parse_string')) {
echo "Skipping orphaned package check because tidy is not installed.\n";
} else {
$data = file_get_contents('http://pear.php.net/qa/packages_orphan.php');
$config = array('indent' => TRUE,
'output-xhtml' => true,
'numeric-entities' => true,
'wrap' => 200);

$tidy = tidy_parse_string($data, $config);
$tidy->cleanRepair();

$document = simplexml_load_string((string)$tidy);
$document->registerXPathNamespace('xhtml', "http://www.w3.org/1999/xhtml");
$qa_package_links = $document->xpath('//xhtml:tr[2]/xhtml:td[1]/xhtml:ul/xhtml:li/xhtml:a');

foreach ($qa_package_links as $node) {
$orphan_packages[] = (string)$node;
}
}

$jenkins_qa_packages = array();
$document = simplexml_load_file('http://test.pear.php.net:8080/view/Unmaintained%20QA%20packages/rssAll');
$document->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
$links = $document->xpath('//atom:link');

foreach ($links as $link) {
// Example content:
// http://test.pear.php.net:8080/job/File_SearchReplace/11/
list(,,,,$jenkins_qa_package) = explode("/", (string)$link["href"]);

$jenkins_qa_packages[] = $jenkins_qa_package;
}
$jenkins_qa_packages = array_unique($jenkins_qa_packages);

$jenkins_packages = array();
$document = simplexml_load_file('http://test.pear.php.net:8080/rssAll');
$document->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
$links = $document->xpath('//atom:link');

foreach ($links as $link) {
// Example content:
// http://test.pear.php.net:8080/job/File_SearchReplace/11/
list(,,,,$jenkins_package) = explode("/", (string)$link["href"]);

$jenkins_packages[] = $jenkins_package;
}
$jenkins_packages = array_unique($jenkins_packages);
/*
* Show results.
*/



$anomalies = array_diff($github, $jenkins_packages);
if ($anomalies) {
echo "---------------\n";
echo "Github packages not on jenkins:\n";
echo implode("\n", $anomalies);
echo "\n";
}

$anomalies = array_diff($packages, $jenkins_packages);
if ($anomalies) {
echo "---------------\n";
echo "PEAR packages not on jenkins:\n";
echo implode("\n", $anomalies);
echo "\n";
}

$anomalies = array_diff(array_intersect($jenkins_packages, $orphan_packages), $jenkins_qa_packages);
if ($anomalies) {
sort($anomalies);
echo "---------------\n";
echo "Orphan packages not on jenkins' unmaintained list, but with a build:\n";
echo implode("\n", $anomalies);
echo "\n";
}
31 changes: 31 additions & 0 deletions admin-mirror-all.php
@@ -0,0 +1,31 @@
<?php
$result = `svn list https://svn.php.net/repository/pear/packages`;
$result = trim($result);
$result = str_replace('/', '', $result);
$packages = preg_split('/[\r\n]+/', $result);

foreach ($packages as $package) {
if ($package == 'installphars') { continue; }
if ($package == 'AllTests.php') { continue; }

$workbench = $package . "-workbench";
if (!file_exists($workbench)) {
$paths = array();
$paths[] = "mkdir ". $workbench;
$paths[] = "cd " . $workbench;
$paths[] = "git-svn-mirror init --authors=../authors.txt --from=http://svn.php.net/repository/pear/packages/" . $package . "/ --to=git@github.com:pear/" . $package . ".git";
$paths[] = "cd ..";
shell_exec(implode("&&", $paths));

}
}

foreach ($packages as $package) {
if ($package == 'installphars') { continue; }
if ($package == 'AllTests.php') { continue; }

$workbench = $package . "-workbench";
if (file_exists($workbench)) {
shell_exec("git-svn-mirror update $workbench");
}
}
4 changes: 4 additions & 0 deletions admin-misplaced.php
Expand Up @@ -53,11 +53,14 @@
$document = simplexml_load_string((string)$tidy);
$document->registerXPathNamespace('xhtml', "http://www.w3.org/1999/xhtml");
$qa_package_links = $document->xpath('//xhtml:tr[2]/xhtml:td[1]/xhtml:ul/xhtml:li/xhtml:a');

foreach ($qa_package_links as $node) {
$orphan_packages[] = (string)$node;
}
}



/*
* Show results.
*/
Expand Down Expand Up @@ -109,3 +112,4 @@
echo implode("\n", $anomalies);
echo "\n";
}

35 changes: 35 additions & 0 deletions admin-ohloh.php
@@ -0,0 +1,35 @@
<?php
/**
* Ohloh API client
*
* To quickly obtain
* $ git clone git://github.com/CloCkWeRX/Ohloh.git && cd Ohloh && pear install package.xml
*
* @see https://github.com/CloCkWeRX/Ohloh
*/
require_once 'Ohloh.php';

$apikey = trim(file_get_contents('ohloh.key')); // @see https://www.ohloh.net/accounts/username/api_keys

$client = new Ohloh($apikey, 'pear');
$document = $client->getAll(array($client, 'getProjectEnlistments'));

$enlistments = array();
foreach ($document->result->enlistment as $enlistment) {
$enlistments[] = trim((string)$enlistment->repository->url);
}

$github = array();
$result = file_get_contents('https://api.github.com/orgs/pear/repos');
$result = json_decode($result);
foreach ($result as $item) {
$github[] = trim('git://github.com/pear/' . trim($item->name) . ".git");
}

print "Things not counted on Ohloh, Oh no!\n";
foreach ($github as $gh) {
if (!in_array($gh, $enlistments)) {
print $gh . "\n";
}
}

2 changes: 2 additions & 0 deletions authors.txt
Expand Up @@ -311,3 +311,5 @@ slaws = Simon Laws <slaws@php.net>
jimw = Jim W <jimw@php.net>
dams = Damien_Seguy <dams@php.net>
wez = Wez Furlong <wez@php.net>
ivonascimento = Ivo Nascimento <iannsp@gmail.com>
janpascal = Jan-Pascal van Best <janpascal@php.net>
114 changes: 114 additions & 0 deletions create-repo.sh
@@ -0,0 +1,114 @@
#! /bin/bash

if [ -z $2 ] ; then
echo "Creates a repository on GitHub and pushes the PEAR package to it."
echo ""
echo "cd into the package's directory, then call this script."
echo ""
echo "Usage: ../2-to-github.sh package username [password]"
echo ""
echo " package: the PEAR package name"
echo " username: your GitHub user name"
echo " password: your GitHub website password (optional). If omitted,"
echo " you will be prompted for it if actions require it."
echo ""
exit 1
fi

package=$1
user=$2
api=https://api.github.com


# Quietly check: are the dependencies installed?

tmp=`curl --version`
if [ $? -ne 0 ] ; then
echo "ERROR: curl must be installed and in your PATH."
exit 1
fi



# Obtain the GitHub website password.

if [ $3 ] ; then
pass=$3
echo ""
echo "NOTICE: password is now optional."
echo "This script will ask for it interactively, if it is required."
echo ""
else
echo ""
echo -n "What is your GitHub website password? "
read -e -s pass
echo ""
fi

if [ -z $pass ] ; then
echo "ERROR: actions taken require a password, but none was provided."
exit 1
fi


# Workaround for some curl installs not acknowledging proxy.

if [ $HTTPS_PROXY ] ; then
curl_args="--proxy $HTTPS_PROXY"
elif [ $http_proxy ] ; then
curl_args="--proxy $http_proxy"
else
curl_args=
fi


# Does the repository exist on GitHub?

response=`curl $curl_args -s -S $api/repos/pear/$package`
if [ $? -ne 0 ] ; then
echo "ERROR: curl had problem calling GitHub search API."
exit 1
elif [[ $response == *'"Not Found"'* ]] ; then
# Repository not there yet; create it in the pear-dev team.

post="{\"name\":\"$package\", \"homepage\":\"http://pear.php.net/package/$package\", \"team_id\":83068, \"has_issues\":false, \"has_wiki\":false}"
response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/orgs/pear/repos`
if [ $? -ne 0 ] ; then
echo "ERROR: curl had problem calling GitHub create API."
exit 1
elif [[ $response == *'"message"'* ]] ; then
# The API returned some other error.
echo "GitHub API create ERROR: $response"
exit 1
fi
elif [[ $response == *'"message"'* ]] ; then
# The API returned some other error.
echo "GitHub API search ERROR: $response"
exit 1
fi


# Create hooks.

post="{\"name\":\"email\", \"config\":{\"address\":\"pear-cvs@lists.php.net\", \"send_from_author\":true}}"
response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/repos/pear/$package/hooks`
if [ $? -ne 0 ] ; then
echo "ERROR: curl had problem calling GitHub email hooks API."
exit 1
elif [[ $response == *'"errors"'* ]] ; then
# The API returned some other error.
echo "GitHub API hooks ERROR: $response"
exit 1
fi

post="{\"name\":\"web\", \"config\":{\"url\":\"http://test.pear.php.net:8080/github-webhook/\"}}"
response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/repos/pear/$package/hooks`
if [ $? -ne 0 ] ; then
echo "ERROR: curl had problem calling GitHub web hooks API."
exit 1
elif [[ $response == *'"errors"'* ]] ; then
# The API returned some other error.
echo "GitHub API hooks ERROR: $response"
exit 1
fi

29 changes: 29 additions & 0 deletions split-package.sh
@@ -0,0 +1,29 @@
echo "We assume you have done:"
echo git clone git@github.com:pear/Validate.git
echo Go hit https://github.com/organizations/pear/repositories/new to make a new repo
git clone git@github.com:pear/Validate_DE.git

cd Validate_DE
git pull git@github.com:pear/Validate.git
git rm -r *

git reset HEAD package_DE.xml
git checkout -- package_DE.xml
git mv package_DE.xml package.xml
git commit -m "Rename package" package.xml
pear list package.xml | grep ".* /" | cut -f 1 -d " " | xargs git reset HEAD
pear list package.xml | grep ".* /" | cut -f 1 -d " " | xargs git checkout --
git commit -m "Splitting off to own package"

cd ..

cd Validate

pear list package_Finance.xml | grep ".* /" | cut -f 1 -d " " | xargs git rm
git rm package_DE.xml
git reset HEAD LICENSE
git checkout -- LICENSE

git commit -m "Splitting off to own package"


0 comments on commit 2bc2f49

Please sign in to comment.