Page MenuHomePhabricator

Do the heavy lifting for git commit hooks
ClosedPublic

Authored by epriestley on Dec 3 2013, 3:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 5:47 PM
Unknown Object (File)
Tue, Dec 17, 9:07 AM
Unknown Object (File)
Thu, Dec 12, 12:52 AM
Unknown Object (File)
Sun, Dec 8, 5:55 PM
Unknown Object (File)
Sun, Dec 8, 3:28 AM
Unknown Object (File)
Fri, Nov 29, 8:32 AM
Unknown Object (File)
Tue, Nov 26, 4:31 PM
Unknown Object (File)
Mon, Nov 25, 4:30 AM
Subscribers

Details

Summary

Ref T4189. This doesn't add any rules yet, but does all the heavy lifting to figure out what's changed and put it in a consuamble (if somewhat ad-hoc) datastructure, which lists all the ref and tag modifications and all the new commits in a consistent way.

From here, it should be fairly straightforward to add top-level rules (e.g., ff pushes only).

Test Plan

Output is huge, see comments.

Diff Detail

Event Timeline

Pushing some branches, with var_dump():

>>> orbital ~/repos/POEMS $ git push --all
Counting objects: 19, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (17/17), 1.26 KiB, done.
Total 17 (delta 15), reused 0 (delta 0)
remote: array(3) {
remote:   [0] =>
remote:   array(9) {
remote:     'old' =>
remote:     string(40) "b327b20eac181b91f9739802111191709be98d66"
remote:     'old.short' =>
remote:     string(8) "b327b20e"
remote:     'new' =>
remote:     string(40) "683d658264a5f10466671c2eeda16edb652e36a7"
remote:     'new.short' =>
remote:     string(8) "683d6582"
remote:     'ref' =>
remote:     string(17) "refs/heads/master"
remote:     'type' =>
remote:     string(6) "branch"
remote:     'operation' =>
remote:     string(6) "update"
remote:     'merge-base' =>
remote:     string(40) "b327b20eac181b91f9739802111191709be98d66"
remote:     'commits' =>
remote:     array(1) {
remote:       [0] =>
remote:       string(40) "683d658264a5f10466671c2eeda16edb652e36a7"
remote:     }
remote:   }
remote:   [1] =>
remote:   array(8) {
remote:     'old' =>
remote:     string(40) "0000000000000000000000000000000000000000"
remote:     'old.short' =>
remote:     string(8) "00000000"
remote:     'new' =>
remote:     string(40) "683d658264a5f10466671c2eeda16edb652e36a7"
remote:     'new.short' =>
remote:     string(8) "683d6582"
remote:     'ref' =>
remote:     string(16) "refs/heads/blarp"
remote:     'type' =>
remote:     string(6) "branch"
remote:     'operation' =>
remote:     string(6) "create"
remote:     'commits' =>
remote:     array(1) {
remote:       [0] =>
remote:       string(40) "683d658264a5f10466671c2eeda16edb652e36a7"
remote:     }
remote:   }
remote:   [2] =>
remote:   array(8) {
remote:     'old' =>
remote:     string(40) "0000000000000000000000000000000000000000"
remote:     'old.short' =>
remote:     string(8) "00000000"
remote:     'new' =>
remote:     string(40) "9ff282eed63779f5d5f7934db70d941f991e0e94"
remote:     'new.short' =>
remote:     string(8) "9ff282ee"
remote:     'ref' =>
remote:     string(15) "refs/heads/herp"
remote:     'type' =>
remote:     string(6) "branch"
remote:     'operation' =>
remote:     string(6) "create"
remote:     'commits' =>
remote:     array(15) {
remote:       [0] =>
remote:       string(40) "9ff282eed63779f5d5f7934db70d941f991e0e94"
remote:       [1] =>
remote:       string(40) "82f7ca080e78abe97907b64261c230c3fc573341"
remote:       [2] =>
remote:       string(40) "d74257ab594d569f88ba9c5269f766d0ff68d4a3"
remote:       [3] =>
remote:       string(40) "0486d07aa3ff58e3693904412bc8978c0fc5143b"
remote:       [4] =>
remote:       string(40) "2dbbf9902fed83fd4fa8bff9be18b1ab63586352"
remote:       [5] =>
remote:       string(40) "8d05fa478547f426851ff192746d0a1e32028d1f"
remote:       [6] =>
remote:       string(40) "7cfde00c1d6c880baf9e40200244fe9fbd3f7cf9"
remote:       [7] =>
remote:       string(40) "29f887c17d4231a052ebc7f1cf5d35e520ba9168"
remote:       [8] =>
remote:       string(40) "7cc1f0b2e8a2a7603ce31083b982486cfecd9932"
remote:       [9] =>
remote:       string(40) "0e73ed469cbec677ef90193c4b6144a9265bc665"
remote:       [10] =>
remote:       string(40) "8f8de23cd8169f849f2218d1d19bef896901d783"
remote:       [11] =>
remote:       string(40) "7b729f7ba8f95f60c2b9a1cfcf9be2bd32b79d35"
remote:       [12] =>
remote:       string(40) "1a283f5d8e62c9b30c82cbea8f69b1a037088a46"
remote:       [13] =>
remote:       string(40) "c98b9ab652de1110e7ad11e4749fae4db25adf79"
remote:       [14] =>
remote:       string(40) "683d658264a5f10466671c2eeda16edb652e36a7"
remote:     }
remote:   }
remote: }
To ssh://dweller@localhost/diffusion/POEMS/
 ! [remote rejected] master -> master (pre-receive hook declined)
 ! [remote rejected] blarp -> blarp (pre-receive hook declined)
 ! [remote rejected] herp -> herp (pre-receive hook declined)
error: failed to push some refs to 'ssh://dweller@localhost/diffusion/POEMS/'

Pushing some tags, with var_dump():

>>> orbital ~/repos/POEMS $ git push --tags
Counting objects: 6, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 446 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: array(2) {
remote:   [0] =>
remote:   array(8) {
remote:     'old' =>
remote:     string(40) "0000000000000000000000000000000000000000"
remote:     'old.short' =>
remote:     string(8) "00000000"
remote:     'new' =>
remote:     string(40) "683d658264a5f10466671c2eeda16edb652e36a7"
remote:     'new.short' =>
remote:     string(8) "683d6582"
remote:     'ref' =>
remote:     string(14) "refs/tags/asdf"
remote:     'type' =>
remote:     string(3) "tag"
remote:     'operation' =>
remote:     string(6) "create"
remote:     'commits' =>
remote:     array(1) {
remote:       [0] =>
remote:       string(40) "683d658264a5f10466671c2eeda16edb652e36a7"
remote:     }
remote:   }
remote:   [1] =>
remote:   array(8) {
remote:     'old' =>
remote:     string(40) "0000000000000000000000000000000000000000"
remote:     'old.short' =>
remote:     string(8) "00000000"
remote:     'new' =>
remote:     string(40) "7733af8359f33fe23fc67f9a8d9c0fb4b8b8019b"
remote:     'new.short' =>
remote:     string(8) "7733af83"
remote:     'ref' =>
remote:     string(14) "refs/tags/qwer"
remote:     'type' =>
remote:     string(3) "tag"
remote:     'operation' =>
remote:     string(6) "create"
remote:     'commits' =>
remote:     array(1) {
remote:       [0] =>
remote:       string(40) "683d658264a5f10466671c2eeda16edb652e36a7"
remote:     }
remote:   }
remote: }
To ssh://dweller@localhost/diffusion/POEMS/
 ! [remote rejected] asdf -> asdf (pre-receive hook declined)
 ! [remote rejected] qwer -> qwer (pre-receive hook declined)
error: failed to push some refs to 'ssh://dweller@localhost/diffusion/POEMS/'
btrahan added inline comments.
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
151

any special reasoning on 8 here and below?

src/applications/diffusion/engine/DiffusionCommitHookEngine.php
151

Some discussion in D7606.

Long ago, we had:

->limitPerCore(1)

...which meant:

->limit(1 * number_of_cpu_cores_on_this_machine)

I think we should restore this at some point. It didn't make it out of Facebook because it's super messy to figure out how many CPU cores a machine has in a cross-platform way and it was an easy thing to cut at the time, but it would be much more correct than hard-coding 8.

The 8 number is just "about the most cores machines probably have, usually".