Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #15 from CloCkWeRX/master

Misc additions
  • Loading branch information...
commit 2bc2f49507bc3dabb48aeb7b5bbfe81aaabd79c0 2 parents 4325fdb + a7ba736
Daniel O'Connor CloCkWeRX authored
107 admin-ci.php
... ... @@ -0,0 +1,107 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Finds misplaced packages in PEAR's svn.php.net and github.com repositories
  5 + *
  6 + * @author Daniel Convissor <danielc@php.net>
  7 + */
  8 +
  9 +// Get github.com packages.
  10 +$github = array();
  11 +$github_not_pushed = array();
  12 +$result = file_get_contents('https://api.github.com/orgs/pear/repos');
  13 +$result = json_decode($result);
  14 +foreach ($result as $item) {
  15 + if ($item->pushed_at) {
  16 + $github[] = $item->name;
  17 + } else {
  18 + $github_not_pushed[] = $item->name;
  19 + }
  20 +}
  21 +
  22 +// Get svn.php.net packages.
  23 +$result = `svn list https://svn.php.net/repository/pear/packages`;
  24 +$result = trim($result);
  25 +$result = str_replace('/', '', $result);
  26 +$packages = preg_split('/[\r\n]+/', $result);
  27 +
  28 +// Get orphaned packages, if possible.
  29 +$orphan_packages = array();
  30 +if (!function_exists('tidy_parse_string')) {
  31 + echo "Skipping orphaned package check because tidy is not installed.\n";
  32 +} else {
  33 + $data = file_get_contents('http://pear.php.net/qa/packages_orphan.php');
  34 + $config = array('indent' => TRUE,
  35 + 'output-xhtml' => true,
  36 + 'numeric-entities' => true,
  37 + 'wrap' => 200);
  38 +
  39 + $tidy = tidy_parse_string($data, $config);
  40 + $tidy->cleanRepair();
  41 +
  42 + $document = simplexml_load_string((string)$tidy);
  43 + $document->registerXPathNamespace('xhtml', "http://www.w3.org/1999/xhtml");
  44 + $qa_package_links = $document->xpath('//xhtml:tr[2]/xhtml:td[1]/xhtml:ul/xhtml:li/xhtml:a');
  45 +
  46 + foreach ($qa_package_links as $node) {
  47 + $orphan_packages[] = (string)$node;
  48 + }
  49 +}
  50 +
  51 +$jenkins_qa_packages = array();
  52 +$document = simplexml_load_file('http://test.pear.php.net:8080/view/Unmaintained%20QA%20packages/rssAll');
  53 +$document->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
  54 +$links = $document->xpath('//atom:link');
  55 +
  56 +foreach ($links as $link) {
  57 + // Example content:
  58 + // http://test.pear.php.net:8080/job/File_SearchReplace/11/
  59 + list(,,,,$jenkins_qa_package) = explode("/", (string)$link["href"]);
  60 +
  61 + $jenkins_qa_packages[] = $jenkins_qa_package;
  62 +}
  63 +$jenkins_qa_packages = array_unique($jenkins_qa_packages);
  64 +
  65 +$jenkins_packages = array();
  66 +$document = simplexml_load_file('http://test.pear.php.net:8080/rssAll');
  67 +$document->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
  68 +$links = $document->xpath('//atom:link');
  69 +
  70 +foreach ($links as $link) {
  71 + // Example content:
  72 + // http://test.pear.php.net:8080/job/File_SearchReplace/11/
  73 + list(,,,,$jenkins_package) = explode("/", (string)$link["href"]);
  74 +
  75 + $jenkins_packages[] = $jenkins_package;
  76 +}
  77 +$jenkins_packages = array_unique($jenkins_packages);
  78 +/*
  79 + * Show results.
  80 + */
  81 +
  82 +
  83 +
  84 +$anomalies = array_diff($github, $jenkins_packages);
  85 +if ($anomalies) {
  86 + echo "---------------\n";
  87 + echo "Github packages not on jenkins:\n";
  88 + echo implode("\n", $anomalies);
  89 + echo "\n";
  90 +}
  91 +
  92 +$anomalies = array_diff($packages, $jenkins_packages);
  93 +if ($anomalies) {
  94 + echo "---------------\n";
  95 + echo "PEAR packages not on jenkins:\n";
  96 + echo implode("\n", $anomalies);
  97 + echo "\n";
  98 +}
  99 +
  100 +$anomalies = array_diff(array_intersect($jenkins_packages, $orphan_packages), $jenkins_qa_packages);
  101 +if ($anomalies) {
  102 + sort($anomalies);
  103 + echo "---------------\n";
  104 + echo "Orphan packages not on jenkins' unmaintained list, but with a build:\n";
  105 + echo implode("\n", $anomalies);
  106 + echo "\n";
  107 +}
31 admin-mirror-all.php
... ... @@ -0,0 +1,31 @@
  1 +<?php
  2 +$result = `svn list https://svn.php.net/repository/pear/packages`;
  3 +$result = trim($result);
  4 +$result = str_replace('/', '', $result);
  5 +$packages = preg_split('/[\r\n]+/', $result);
  6 +
  7 +foreach ($packages as $package) {
  8 + if ($package == 'installphars') { continue; }
  9 + if ($package == 'AllTests.php') { continue; }
  10 +
  11 + $workbench = $package . "-workbench";
  12 + if (!file_exists($workbench)) {
  13 + $paths = array();
  14 + $paths[] = "mkdir ". $workbench;
  15 + $paths[] = "cd " . $workbench;
  16 + $paths[] = "git-svn-mirror init --authors=../authors.txt --from=http://svn.php.net/repository/pear/packages/" . $package . "/ --to=git@github.com:pear/" . $package . ".git";
  17 + $paths[] = "cd ..";
  18 + shell_exec(implode("&&", $paths));
  19 +
  20 + }
  21 +}
  22 +
  23 +foreach ($packages as $package) {
  24 + if ($package == 'installphars') { continue; }
  25 + if ($package == 'AllTests.php') { continue; }
  26 +
  27 + $workbench = $package . "-workbench";
  28 + if (file_exists($workbench)) {
  29 + shell_exec("git-svn-mirror update $workbench");
  30 + }
  31 +}
4 admin-misplaced.php
@@ -53,11 +53,14 @@
53 53 $document = simplexml_load_string((string)$tidy);
54 54 $document->registerXPathNamespace('xhtml', "http://www.w3.org/1999/xhtml");
55 55 $qa_package_links = $document->xpath('//xhtml:tr[2]/xhtml:td[1]/xhtml:ul/xhtml:li/xhtml:a');
  56 +
56 57 foreach ($qa_package_links as $node) {
57 58 $orphan_packages[] = (string)$node;
58 59 }
59 60 }
60 61
  62 +
  63 +
61 64 /*
62 65 * Show results.
63 66 */
@@ -109,3 +112,4 @@
109 112 echo implode("\n", $anomalies);
110 113 echo "\n";
111 114 }
  115 +
35 admin-ohloh.php
... ... @@ -0,0 +1,35 @@
  1 +<?php
  2 +/**
  3 + * Ohloh API client
  4 + *
  5 + * To quickly obtain
  6 + * $ git clone git://github.com/CloCkWeRX/Ohloh.git && cd Ohloh && pear install package.xml
  7 + *
  8 + * @see https://github.com/CloCkWeRX/Ohloh
  9 + */
  10 +require_once 'Ohloh.php';
  11 +
  12 +$apikey = trim(file_get_contents('ohloh.key')); // @see https://www.ohloh.net/accounts/username/api_keys
  13 +
  14 +$client = new Ohloh($apikey, 'pear');
  15 +$document = $client->getAll(array($client, 'getProjectEnlistments'));
  16 +
  17 +$enlistments = array();
  18 +foreach ($document->result->enlistment as $enlistment) {
  19 + $enlistments[] = trim((string)$enlistment->repository->url);
  20 +}
  21 +
  22 +$github = array();
  23 +$result = file_get_contents('https://api.github.com/orgs/pear/repos');
  24 +$result = json_decode($result);
  25 +foreach ($result as $item) {
  26 + $github[] = trim('git://github.com/pear/' . trim($item->name) . ".git");
  27 +}
  28 +
  29 +print "Things not counted on Ohloh, Oh no!\n";
  30 +foreach ($github as $gh) {
  31 + if (!in_array($gh, $enlistments)) {
  32 + print $gh . "\n";
  33 + }
  34 +}
  35 +
2  authors.txt
@@ -311,3 +311,5 @@ slaws = Simon Laws <slaws@php.net>
311 311 jimw = Jim W <jimw@php.net>
312 312 dams = Damien_Seguy <dams@php.net>
313 313 wez = Wez Furlong <wez@php.net>
  314 +ivonascimento = Ivo Nascimento <iannsp@gmail.com>
  315 +janpascal = Jan-Pascal van Best <janpascal@php.net>
114 create-repo.sh
... ... @@ -0,0 +1,114 @@
  1 +#! /bin/bash
  2 +
  3 +if [ -z $2 ] ; then
  4 + echo "Creates a repository on GitHub and pushes the PEAR package to it."
  5 + echo ""
  6 + echo "cd into the package's directory, then call this script."
  7 + echo ""
  8 + echo "Usage: ../2-to-github.sh package username [password]"
  9 + echo ""
  10 + echo " package: the PEAR package name"
  11 + echo " username: your GitHub user name"
  12 + echo " password: your GitHub website password (optional). If omitted,"
  13 + echo " you will be prompted for it if actions require it."
  14 + echo ""
  15 + exit 1
  16 +fi
  17 +
  18 +package=$1
  19 +user=$2
  20 +api=https://api.github.com
  21 +
  22 +
  23 +# Quietly check: are the dependencies installed?
  24 +
  25 +tmp=`curl --version`
  26 +if [ $? -ne 0 ] ; then
  27 + echo "ERROR: curl must be installed and in your PATH."
  28 + exit 1
  29 +fi
  30 +
  31 +
  32 +
  33 +# Obtain the GitHub website password.
  34 +
  35 +if [ $3 ] ; then
  36 + pass=$3
  37 + echo ""
  38 + echo "NOTICE: password is now optional."
  39 + echo "This script will ask for it interactively, if it is required."
  40 + echo ""
  41 +else
  42 + echo ""
  43 + echo -n "What is your GitHub website password? "
  44 + read -e -s pass
  45 + echo ""
  46 +fi
  47 +
  48 +if [ -z $pass ] ; then
  49 + echo "ERROR: actions taken require a password, but none was provided."
  50 + exit 1
  51 +fi
  52 +
  53 +
  54 +# Workaround for some curl installs not acknowledging proxy.
  55 +
  56 +if [ $HTTPS_PROXY ] ; then
  57 + curl_args="--proxy $HTTPS_PROXY"
  58 +elif [ $http_proxy ] ; then
  59 + curl_args="--proxy $http_proxy"
  60 +else
  61 + curl_args=
  62 +fi
  63 +
  64 +
  65 +# Does the repository exist on GitHub?
  66 +
  67 +response=`curl $curl_args -s -S $api/repos/pear/$package`
  68 +if [ $? -ne 0 ] ; then
  69 + echo "ERROR: curl had problem calling GitHub search API."
  70 + exit 1
  71 +elif [[ $response == *'"Not Found"'* ]] ; then
  72 + # Repository not there yet; create it in the pear-dev team.
  73 +
  74 + post="{\"name\":\"$package\", \"homepage\":\"http://pear.php.net/package/$package\", \"team_id\":83068, \"has_issues\":false, \"has_wiki\":false}"
  75 + response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/orgs/pear/repos`
  76 + if [ $? -ne 0 ] ; then
  77 + echo "ERROR: curl had problem calling GitHub create API."
  78 + exit 1
  79 + elif [[ $response == *'"message"'* ]] ; then
  80 + # The API returned some other error.
  81 + echo "GitHub API create ERROR: $response"
  82 + exit 1
  83 + fi
  84 +elif [[ $response == *'"message"'* ]] ; then
  85 + # The API returned some other error.
  86 + echo "GitHub API search ERROR: $response"
  87 + exit 1
  88 +fi
  89 +
  90 +
  91 +# Create hooks.
  92 +
  93 +post="{\"name\":\"email\", \"config\":{\"address\":\"pear-cvs@lists.php.net\", \"send_from_author\":true}}"
  94 +response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/repos/pear/$package/hooks`
  95 +if [ $? -ne 0 ] ; then
  96 + echo "ERROR: curl had problem calling GitHub email hooks API."
  97 + exit 1
  98 +elif [[ $response == *'"errors"'* ]] ; then
  99 + # The API returned some other error.
  100 + echo "GitHub API hooks ERROR: $response"
  101 + exit 1
  102 +fi
  103 +
  104 +post="{\"name\":\"web\", \"config\":{\"url\":\"http://test.pear.php.net:8080/github-webhook/\"}}"
  105 +response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/repos/pear/$package/hooks`
  106 +if [ $? -ne 0 ] ; then
  107 + echo "ERROR: curl had problem calling GitHub web hooks API."
  108 + exit 1
  109 +elif [[ $response == *'"errors"'* ]] ; then
  110 + # The API returned some other error.
  111 + echo "GitHub API hooks ERROR: $response"
  112 + exit 1
  113 +fi
  114 +
29 split-package.sh
... ... @@ -0,0 +1,29 @@
  1 +echo "We assume you have done:"
  2 +echo git clone git@github.com:pear/Validate.git
  3 +echo Go hit https://github.com/organizations/pear/repositories/new to make a new repo
  4 +git clone git@github.com:pear/Validate_DE.git
  5 +
  6 +cd Validate_DE
  7 +git pull git@github.com:pear/Validate.git
  8 +git rm -r *
  9 +
  10 +git reset HEAD package_DE.xml
  11 +git checkout -- package_DE.xml
  12 +git mv package_DE.xml package.xml
  13 +git commit -m "Rename package" package.xml
  14 +pear list package.xml | grep ".* /" | cut -f 1 -d " " | xargs git reset HEAD
  15 +pear list package.xml | grep ".* /" | cut -f 1 -d " " | xargs git checkout --
  16 +git commit -m "Splitting off to own package"
  17 +
  18 +cd ..
  19 +
  20 +cd Validate
  21 +
  22 +pear list package_Finance.xml | grep ".* /" | cut -f 1 -d " " | xargs git rm
  23 +git rm package_DE.xml
  24 +git reset HEAD LICENSE
  25 +git checkout -- LICENSE
  26 +
  27 +git commit -m "Splitting off to own package"
  28 +
  29 +

0 comments on commit 2bc2f49

Please sign in to comment.
Something went wrong with that request. Please try again.