|
| 1 | +#!/bin/bash |
| 2 | +# Reproduces the history and content of https://github.com/staehle/gitoxide-testing |
| 3 | +# for use in journey tests without requiring network access. |
| 4 | +# |
| 5 | +# Note: This script is designed to be run via `jtt run-script` which sets up |
| 6 | +# a controlled Git environment with fixed author/committer dates. The resulting |
| 7 | +# commit hashes will differ from the original repository but the content and |
| 8 | +# structure will be semantically equivalent. |
| 9 | +set -eu -o pipefail |
| 10 | + |
| 11 | +git init -q |
| 12 | + |
| 13 | +# Configure the repository to allow partial clone filters when served via file:// |
| 14 | +git config uploadpack.allowFilter true |
| 15 | +git config uploadpack.allowAnySHA1InWant true |
| 16 | + |
| 17 | +# Initial commit (simulating GitHub's initial commit) |
| 18 | +cat > LICENSE << 'EOF' |
| 19 | +MIT License |
| 20 | +
|
| 21 | +Copyright (c) 2026 Jake Staehle |
| 22 | +
|
| 23 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 24 | +of this software and associated documentation files (the "Software"), to deal |
| 25 | +in the Software without restriction, including without limitation the rights |
| 26 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 27 | +copies of the Software, and to permit persons to whom the Software is |
| 28 | +furnished to do so, subject to the following conditions: |
| 29 | +
|
| 30 | +The above copyright notice and this permission notice shall be included in all |
| 31 | +copies or substantial portions of the Software. |
| 32 | +
|
| 33 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 34 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 35 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 36 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 37 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 38 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 39 | +SOFTWARE. |
| 40 | +EOF |
| 41 | + |
| 42 | +cat > README.md << 'EOF' |
| 43 | +# gitoxide-testing |
| 44 | +example repo to use in gitoxide functional tests |
| 45 | +EOF |
| 46 | + |
| 47 | +git add LICENSE README.md |
| 48 | +git commit -q -m "Initial commit" |
| 49 | + |
| 50 | +# Version 1 commit |
| 51 | +cat > README.md << 'EOF' |
| 52 | +# gitoxide-testing |
| 53 | +Example repo to use in gitoxide functional tests |
| 54 | +
|
| 55 | +For use with journey tests in: https://github.com/GitoxideLabs/gitoxide |
| 56 | +
|
| 57 | +EOF |
| 58 | + |
| 59 | +echo "This is version 1.0" > version.txt |
| 60 | +git add README.md version.txt |
| 61 | +git commit -q -m "version 1 commit" |
| 62 | +git tag v1 |
| 63 | + |
| 64 | +# Version 2 commit |
| 65 | +echo "This is version 2.0" > version.txt |
| 66 | +touch new-file-in-v2 |
| 67 | +git add version.txt new-file-in-v2 |
| 68 | +git commit -q -m "version 2" |
| 69 | +git tag v2 |
| 70 | + |
| 71 | +# Commit between versions - removes new-file-in-v2, adds another-new-file, updates version |
| 72 | +echo "This is version 2.1" > version.txt |
| 73 | +echo "This should exist starting in version 2" > another-new-file |
| 74 | +git rm -q new-file-in-v2 |
| 75 | +git add version.txt another-new-file |
| 76 | +git commit -q -m "a commit between versions" |
| 77 | + |
| 78 | +# Adds a script (non-executable) |
| 79 | +cat > a_script.sh << 'EOF' |
| 80 | +#!/bin/sh |
| 81 | +
|
| 82 | +echo "This is a script!" |
| 83 | +echo "It does things!" |
| 84 | +
|
| 85 | +exit 0 |
| 86 | +EOF |
| 87 | +git add a_script.sh |
| 88 | +git commit -q -m "adds a script (non-executable)" |
| 89 | + |
| 90 | +# Version 3 commit |
| 91 | +echo "This is version 3.0" > version.txt |
| 92 | +git add version.txt |
| 93 | +git commit -q -m "version 3" |
| 94 | +git tag v3 |
| 95 | + |
| 96 | +# Make script executable |
| 97 | +chmod +x a_script.sh |
| 98 | +git add a_script.sh |
| 99 | +git commit -q -m "just changes the file mode for a_script.sh from 644 to 755" |
| 100 | + |
| 101 | +# Version 4 commit |
| 102 | +echo "This is version 4.0" > version.txt |
| 103 | + |
| 104 | +cat > CHANGELOG.md << 'EOF' |
| 105 | +# Summary of commits in this repo and what to test for: |
| 106 | +
|
| 107 | +1. `v1`: Just adds `version.txt` and updates the README |
| 108 | +2. `v2`: Immediately after v1, adds `new-file-in-v2`, and updates `version.txt` (all tags should have bumped versions of this) |
| 109 | +3. `v3`: Has three commits after v2, adds `another-new-file` and a non-executable script `a_script.sh` |
| 110 | +4. `v4`: Fixes the script to be executable |
| 111 | +EOF |
| 112 | + |
| 113 | +git add version.txt CHANGELOG.md |
| 114 | +git commit -q -m "version 4" |
| 115 | +git tag v4 |
| 116 | + |
| 117 | +# Version 5 commit |
| 118 | +cat > README.md << 'EOF' |
| 119 | +# gitoxide-testing |
| 120 | +Example repo to use in gitoxide functional tests |
| 121 | +
|
| 122 | +For use with journey tests in: https://github.com/GitoxideLabs/gitoxide |
| 123 | +
|
| 124 | +# Summary of commits in this repo and what to test for: |
| 125 | +
|
| 126 | +1. `v1`: Just adds `version.txt` and updates the README |
| 127 | +2. `v2`: Immediately after v1, adds `new-file-in-v2`, and updates `version.txt` (all tags should have bumped versions of this) |
| 128 | +3. `v3`: Has three commits after v2, adds `another-new-file` and a non-executable script `a_script.sh` |
| 129 | +4. `v4`: Fixes the script to be executable |
| 130 | +5. `v5`: Removes `another-new-file` and moves the changelog to readme |
| 131 | +EOF |
| 132 | + |
| 133 | +# Note: Despite the README saying v5 removes another-new-file, the original repo still has it at v5 |
| 134 | +git rm -q CHANGELOG.md |
| 135 | +git add README.md |
| 136 | +git commit -q -m "version 5" |
| 137 | +git tag v5 |
0 commit comments