File: sync-packages.php

package info (click to toggle)
symfony 7.4.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 137,496 kB
  • sloc: php: 1,599,879; xml: 7,154; javascript: 979; sh: 591; makefile: 311; pascal: 70
file content (57 lines) | stat: -rw-r--r-- 1,717 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php

if ('cli' !== PHP_SAPI) {
    echo "This script can only be run from the command line.\n";
    exit(1);
}

$mainRepo = 'https://github.com/symfony/symfony';
exec('find src -name composer.json', $packages);

foreach ($packages as $package) {
    $package = dirname($package);
    $c = file_get_contents($package.'/.gitattributes');
    $c = preg_replace('{^/\.git.*+\n}m', '', $c);
    $c .= "/.git* export-ignore\n";
    file_put_contents($package.'/.gitattributes', $c);

    @mkdir($package.'/.github');
    file_put_contents($package.'/.github/PULL_REQUEST_TEMPLATE.md', <<<EOTXT
        Please do not submit any Pull Requests here. They will be closed.
        ---

        Please submit your PR here instead:
        {$mainRepo}

        This repository is what we call a "subtree split": a read-only subset of that main repository.
        We're looking forward to your PR there!

        EOTXT
    );

    @mkdir($package.'/.github/workflows');
    file_put_contents($package.'/.github/workflows/close-pull-request.yml', <<<EOTXT
        name: Close Pull Request

        on:
          pull_request_target:
            types: [opened]

        jobs:
          run:
            runs-on: ubuntu-latest
            steps:
            - uses: superbrothers/close-pull-request@v3
              with:
                comment: |
                  Thanks for your Pull Request! We love contributions.

                  However, you should instead open your PR on the main repository:
                  {$mainRepo}

                  This repository is what we call a "subtree split": a read-only subset of that main repository.
                  We're looking forward to your PR there!

        EOTXT
    );
}