Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated git instructions

- Indicated purpose of each branch
- Updated pre-commit
  - do not run for whole framework; loop over files in commit
  - omit deleted files
  - skip non-php files
  - run linter first
  • Loading branch information...
commit 37856b4f796545079d61c0e06e8e41487abcef04 1 parent 2a398b4
Matthew Weier O'Phinney authored September 17, 2012

Showing 2 changed files with 148 additions and 104 deletions. Show diff stats Hide diff stats

  1. 71  README-DEV.md
  2. 181  README-GIT.md
71  README-DEV.md
Source Rendered
@@ -5,19 +5,17 @@
5 5
 If you wish to contribute to Zend Framework, please be sure to
6 6
 read/subscribe to the following resources:
7 7
 
8  
- -  ZF2 Requirements:
9  
-    http://framework.zend.com/wiki/display/ZFDEV2/Zend+Framework+2.0+Requirements
10 8
  -  Coding Standards:
11 9
     http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards
12 10
  -  ZF Git Guide:
13 11
     [README-GIT.md](README-GIT.md)
14 12
  -  Contributor's Guide:
15  
-    http://framework.zend.com/wiki/display/ZFDEV/Contributing+to+Zend+Framework
  13
+    http://framework.zend.com/participate/contributor-guide
16 14
  -  ZF Contributor's mailing list:
17 15
     Archives: http://zend-framework-community.634137.n4.nabble.com/ZF-Contributor-f680267.html
18 16
     Subscribe: zf-contributors-subscribe@lists.zend.com
19 17
  -  ZF Contributor's IRC channel:
20  
-    #zftalk.2 on Freenode.net
  18
+    #zftalk.dev on Freenode.net
21 19
 
22 20
 If you are working on new features, or refactoring an existing
23 21
 component, please create a proposal. You can do this in on the RFC's
@@ -31,29 +29,48 @@ issues we've encountered in refactoring.
31 29
 
32 30
 To run tests:
33 31
 
34  
- -  Make sure you have a recent version of PHPUnit installed; 3.6.0
35  
-    minimally.
36  
- -  Enter the `tests/` subdirectory.
37  
- -  Execute PHPUnit, providing a path to a component directory for which
38  
-    you wish to run tests, or a specific test class file.
39  
-
40  
-    ```sh
41  
-    % phpunit Zend/Http
42  
-    % phpunit Zend/Http/Header/EtagTest.php
43  
-    ```
44  
-
45  
- -  You may also provide the `--group` switch; in such cases, provide the
46  
-    top-level component name:
47  
-
48  
-    ```sh
49  
-    % phpunit --group Zend_Http
50  
-    ```
51  
-    This will likely lead to errors, so it's usually best to specify a
52  
-    specific component in which to run test:
53  
-
54  
-    ```sh
55  
-    % phpunit --group ZF-XYZ Zend/Http
56  
-    ```
  32
+- Make sure you have a recent version of PHPUnit installed; 3.6.0
  33
+  minimally.
  34
+- Enter the `tests/` subdirectory.
  35
+- Execute PHPUnit, providing a path to a component directory for which
  36
+  you wish to run tests, or a specific test class file.
  37
+
  38
+  ```sh
  39
+  % phpunit ZendTest/Http
  40
+  % phpunit ZendTest/Http/Header/EtagTest.php
  41
+  ```
  42
+
  43
+- You may also provide the `--group` switch; in such cases, provide the
  44
+  top-level component name:
  45
+
  46
+  ```sh
  47
+  % phpunit --group Zend_Http
  48
+  ```
  49
+
  50
+  This will likely lead to errors, so it's usually best to specify a
  51
+  specific component in which to run test:
  52
+
  53
+  ```sh
  54
+  % phpunit --group ZF-XYZ Zend/Http
  55
+  ```
  56
+- Alternately, use the `run-tests.php` script. This can be executed with no
  57
+  arguments to run all tests:
  58
+
  59
+  ```sh
  60
+  % php run-tests.php
  61
+  ```
  62
+
  63
+  You can also provide top-level component names to run tests for individual
  64
+  components or several components at a time. The component name is the the
  65
+  component namespace, without the `Zend\` prefix:
  66
+
  67
+  ```sh
  68
+  % php run-tests Mvc
  69
+  ```
  70
+
  71
+  ```sh
  72
+  % php run-tests ModuleManager Mvc View Navigation
  73
+  ```
57 74
 
58 75
 You can turn on conditional tests with the TestConfiguration.php file.
59 76
 To do so:
181  README-GIT.md
Source Rendered
... ...
@@ -1,25 +1,15 @@
1 1
 # USING THE GIT REPOSITORY
2 2
 
3  
-## Initial Setup
4  
-
5  
-First, make sure you know the email address associated with your JIRA
6  
-credentials. All commits pushed to the master repository are checked
7  
-against these addresses, so your repository will need to be configured
8  
-to use that address. The following will give you that information:
9  
-
10  
- 1. Visit the ZF Crowd install: http://framework.zend.com/crowd
11  
- 2. Log in, if you aren't.
12  
- 3. Find the "My Profile" link in the upper right of the page, and follow
13  
-    it.
14  
- 4. The resulting page will display your profile, including the _email_
15  
-    address with which you are registered. Make a note of it.
16  
-
17 3
 ## Setup your own public repository
18 4
 
19  
-Your next step is to establish a public repository from which we can
  5
+Your first step is to establish a public repository from which we can
20 6
 pull your work into the master repository. You have two options: use
21 7
 github or other public site, or setup/use your own repository.
22 8
 
  9
+While you can use a private repository and utilize ``git format-patch`` to
  10
+submit patches, this is discouraged as it does not facilitate public peer
  11
+review.
  12
+
23 13
 ### Option 1: GitHub
24 14
 
25 15
  1. Setup a GitHub account (http://github.com/), if you haven't yet
@@ -32,14 +22,7 @@ github or other public site, or setup/use your own repository.
32 22
     % cd zf2
33 23
     ```
34 24
 
35  
- 4. Configure git to use the email address with which you are registered
36  
-    in JIRA:
37  
-
38  
-    ```sh
39  
-    % git config user.email <your email address>
40  
-    ```
41  
-
42  
- 5. Add a remote to the canonical ZF repository, so you can keep your fork
  25
+ 4. Add a remote to the canonical ZF repository, so you can keep your fork
43 26
     up-to-date:
44 27
 
45 28
     ```sh
@@ -49,10 +32,10 @@ github or other public site, or setup/use your own repository.
49 32
 
50 33
 ### Option 2: Personal Repository
51 34
 
52  
-We assume you will use gitosis (http://progit.org/book/ch4-7.html) or gitolite
53  
-(http://progit.org/book/ch4-8.html) to host your own repository.  If
54  
-you go this route, we will assume you have the knowledge to do so, or
55  
-know where to obtain it. We will not assist you in setting up such a
  35
+We assume you will use gitosis (http://git-scm.com/book/en/Git-on-the-Server-Gitosis)
  36
+or gitolite (http://git-scm.com/book/en/Git-on-the-Server-Gitolite) to host your
  37
+own repository.  If you go this route, we will assume you have the knowledge to
  38
+do so, or know where to obtain it. We will not assist you in setting up such a
56 39
 repository.
57 40
 
58 41
  1.  Create a new repository
@@ -61,33 +44,26 @@ repository.
61 44
     % git init
62 45
     ```
63 46
 
64  
- 2. Configure git to use the email address with which you are registered
65  
-    in JIRA:
66  
-
67  
-    ```sh
68  
-    % git config user.email <your email address>
69  
-    ```
70  
-
71  
- 3. Add an "origin" remote pointing to your gitosis/gitolite repo:
  47
+ 2. Add an "origin" remote pointing to your gitosis/gitolite repo:
72 48
 
73 49
     ```sh
74 50
     % git remote add origin git://yourdomain/yourrepo.git
75 51
     ```
76 52
 
77  
- 4. Add a remote for the ZF repository and fetch it
  53
+ 3. Add a remote for the ZF repository and fetch it
78 54
 
79 55
     ```sh
80 56
     % git remote add zf2 https://github.com/zendframework/zf2.git
81 57
     % git fetch zf2
82 58
     ```
83 59
 
84  
- 5. Create a new branch for the ZF repository (named "zf/master" here)
  60
+ 4. Create a new branch for the ZF repository (named "zf/master" here)
85 61
 
86 62
     ```sh
87 63
     % git checkout -b zf/master zf2/master
88 64
     ```
89 65
 
90  
- 6. Create your master branch off the ZF branch, and push to your
  66
+ 5. Create your master branch off the ZF branch, and push to your
91 67
     repository
92 68
 
93 69
     ```sh
@@ -100,29 +76,80 @@ repository.
100 76
 The ZF2 Travis-CI will confirm that code style standards are met 
101 77
 by using ```php-cs-fixer``` (https://github.com/fabpot/PHP-CS-Fixer) during it's build runs.
102 78
 
103  
-To reduce the number of red Travis-CI builds, the following Git pre-commit hook can help catch code style 
104  
-issues before committing.
  79
+To reduce the number of red Travis-CI builds, the following Git pre-commit hook
  80
+can help catch code style issues before committing. Save it as
  81
+```.git/hooks/pre-commit```, and make sure it is executable.
105 82
 
106 83
 ```sh
107  
-#!/bin/sh
108  
-# Git pre-commit hook to confirm ZF2 code style
109  
-# Install under: zf2/.git/hooks/pre-commit (and ensure it is executable)
110  
-
111  
-PROJECTROOT=`echo $(cd ${0%/*}/../../ && pwd -P)`/
112  
-FIXER=php-cs-fixer
113  
-
114  
-RES=`${FIXER} fix $PROJECTROOT -v --dry-run --level=psr2`
115  
-if [ "$RES" != "" ]; then
116  
-    echo "ZF2 Coding standards are not correct, cancelling your commit."
117  
-    echo ""
118  
-    echo $RES
119  
-    echo ""
120  
-    echo "To fix, run:"
121  
-    echo ""
122  
-    echo "    ${FIXER} fix ${PROJECTROOT} -v --level=psr2"
123  
-    echo ""
124  
-    exit 1
125  
-fi  
  84
+#!/usr/bin/env php
  85
+<?php
  86
+/**
  87
+ * .git/hooks/pre-commit
  88
+ * 
  89
+ * This pre-commit hooks will check for PHP errors (lint), and make sure the 
  90
+ * code is PSR-2 compliant.
  91
+ * 
  92
+ * Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
  93
+ * 
  94
+ * @author  Mardix  http://github.com/mardix 
  95
+ * @author  Matthew Weier O'Phinney http://mwop.net/
  96
+ * @since   4 Sept 2012
  97
+ */
  98
+
  99
+$exit = 0;
  100
+
  101
+/*
  102
+ * collect all files which have been added, copied or
  103
+ * modified and store them in an array called output
  104
+ */
  105
+$output = array();
  106
+exec('git diff --cached --name-status --diff-filter=ACM', $output);
  107
+
  108
+foreach ($output as $file) {
  109
+    if ('D' === substr($file, 0, 1)) {
  110
+        // deleted file; do nothing
  111
+        continue;
  112
+    }
  113
+
  114
+    $fileName = trim(substr($file, 1));
  115
+
  116
+    /*
  117
+     * Only PHP files
  118
+     */
  119
+    $extension = pathinfo($fileName, PATHINFO_EXTENSION);
  120
+    if (!preg_match('/^ph(p|tml)$/', $extension)) {
  121
+        continue;
  122
+    }
  123
+
  124
+    /*
  125
+     * Check for parse errors
  126
+     */
  127
+    $output = array();
  128
+    $return = 0;
  129
+    exec("php -l " . escapeshellarg($fileName), $output, $return);
  130
+
  131
+    if ($return != 0) {
  132
+        echo "PHP file fails to parse: " . $fileName . ":" . PHP_EOL;
  133
+        echo implode(PHP_EOL, $lintOutput) . PHP_EOL;
  134
+        $exit = 1;
  135
+        continue;
  136
+    }
  137
+
  138
+    /*
  139
+     * PHP-CS-Fixer
  140
+     */
  141
+    $output = array();
  142
+    $return = null;
  143
+    exec("php-cs-fixer --dry-run --level=psr2 " . escapeshellarg($fileName), $output, $return);
  144
+    if ($return != 0) {
  145
+        echo "PHP file fails contains CS issues: " . $fileName . ":" . PHP_EOL;
  146
+        echo implode(PHP_EOL, $output) . PHP_EOL;
  147
+        $exit = 1;
  148
+        continue;
  149
+    }
  150
+}
  151
+
  152
+exit($exit);
126 153
 ```
127 154
 
128 155
 ## Keeping Up-to-Date
@@ -140,6 +167,10 @@ the following:
140 167
 % git push origin
141 168
 ```
142 169
 
  170
+If you're tracking other branches -- for example, the "develop" branch, where
  171
+new feature development occurs -- you'll want to do the same operations for that
  172
+branch; simply substibute "develop" for "master".
  173
+
143 174
 ## Working on Zend Framework
144 175
 
145 176
 When working on Zend Framework, we recommend you do each new feature or
@@ -199,6 +230,16 @@ email indicating you have changes to pull:
199 230
      -  The nature of the changes (e.g., `implements
200 231
         Zend_Service_Twitter`, `fixes ZF-9295`, etc.)
201 232
 
  233
+### What branch to issue the pull request against?
  234
+
  235
+Which branch should you issue a pull request against?
  236
+
  237
+- For fixes against the stable release, issue the pull request against the
  238
+  "master" branch.
  239
+- For new features, or fixes that introduce new elements to the public API (such
  240
+  as new public methods or properties), issue the pull request against the
  241
+  "develop" branch.
  242
+
202 243
 ## Branch Cleanup
203 244
 
204 245
 As you might imagine, if you are a frequent contributor, you'll start to
@@ -228,24 +269,10 @@ RSS feeds may be found at:
228 269
 
229 270
 where &lt;branch&gt; is a branch in the repository.
230 271
 
231  
-To subscribe to git email notifications, send an email to:
232  
-
233  
-<zf-git-subscribe@lists.zend.com>
234  
-
235  
-You will need to reply to the verification email sent to you by this
236  
-list.
237  
-
238  
-Should you wish to filter emails from the list, they will use the
239  
-"subject" line of commit messages, preceded by `[branch] `, and come
240  
-from <zf-git@lists.zend.com>.
  272
+To subscribe to git email notifications, simply watch or fork the zf2 repository
  273
+on GitHub.
241 274
 
242 275
 ## CONTRIBUTORS AND COMMITTERS
243 276
 
244  
-For the immediate future, and until we create a community process team,
245  
-only the Zend team will be committers. If you have a patch or
246  
-feature-set you wish to have incorporated into the repository, please
247  
-issue a pull request to a committer. A pull request may be done by using
248  
-git's "git-send-email" functionality, or by sending a request to a
249  
-committer indicating the URL of your repository, the branch that should
250  
-be pulled, and/or the specific revision(s) to pull.
251  
-
  277
+Both Zend's internal Zend Framework team and the members of the Community Review
  278
+team have push privileges to the ZF2 repository. 

0 notes on commit 37856b4

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