79 lines
3.3 KiB
Markdown
79 lines
3.3 KiB
Markdown
# repo-fix
|
|
|
|
Fix Dandaedre Gitea submodule URLs after cloning, pulling, or syncing:
|
|
|
|
- `.gitmodules` uses HTTPS for CI: `https://proxy.dandaedre.com/gitea/Beffroi/reportist.git`
|
|
- `.git/config` uses SSH locally: `git@git.dandaedre.com:Beffroi/reportist.git`
|
|
|
|
Requires Python 3 and Git on your PATH. No pip packages are needed; the script
|
|
uses the Python standard library and Git's config commands.
|
|
|
|
Preview the changes, then apply them:
|
|
|
|
```bash
|
|
python3 fix_submodules.py /path/to/repository --dry-run
|
|
python3 fix_submodules.py /path/to/repository
|
|
```
|
|
|
|
The repository defaults to the current directory, and may also be a directory
|
|
inside a working tree. Run the script again whenever a pull or `git submodule
|
|
sync` changes the URLs. Repeated runs are safe. Dry runs do not write files.
|
|
|
|
Recognizes HTTP(S), SSH, Git protocol, and SCP-style URLs on `dandaedre.com`,
|
|
`git.dandaedre.com`, and `proxy.dandaedre.com`. Old URLs such as
|
|
`git@dandaedre.com:Beffroi/reportist.git` are corrected. Repository paths and
|
|
`.git` suffixes are preserved; the proxy's `/gitea/` prefix is translated.
|
|
|
|
Missing local URL entries are added from `.gitmodules`. Existing local URLs
|
|
retain their own repository paths. Other hosts and relative URLs are skipped.
|
|
Unrelated configuration, including `active`, is preserved.
|
|
|
|
Works with `.git` directories and pointer files, including linked worktrees
|
|
(whose local config is shared). Only the selected repository's submodule
|
|
entries are changed. The script does not recurse, change `origin` remotes, or
|
|
fetch anything. Run it separately inside submodules with their own declarations.
|
|
|
|
Commit `.gitmodules` changes for CI. Local config changes are not committed.
|
|
After fixing URLs, initialize submodules with:
|
|
|
|
```bash
|
|
git -C /path/to/repository submodule update --init --recursive
|
|
```
|
|
|
|
Run tests:
|
|
|
|
```bash
|
|
python3 -m unittest discover -s tests -v
|
|
```
|
|
|
|
## Jenkins test CI
|
|
|
|
The `Jenkinsfile` uses the `rust_no_docker` agent from the Ravenous pipeline.
|
|
Configure a Jenkins Pipeline from SCM (or a multibranch pipeline) for this
|
|
repository with script path `Jenkinsfile`. The agent needs `python3` and `git`
|
|
on PATH and network access to the Gitea HTTPS proxy. No uv, Docker, or package
|
|
installation is required. Use the Gitea webhook URL from the Jenkinsfile if
|
|
your Jenkins Gitea integration is configured at that address.
|
|
|
|
Every build runs the unit tests. By default, it also shallow-clones
|
|
`Ravenous/ravenous_roll20.git` through the HTTPS proxy into a temporary directory
|
|
and verifies dry-run safety, both URL formats, repeatability, recovery after
|
|
`git submodule sync`, and correction of the old SSH hostname. The clone is
|
|
removed after the test. It does not fetch submodules or run code from Ravenous;
|
|
SSH connectivity and recursive submodule downloads are not tested.
|
|
|
|
Run the same network test locally:
|
|
|
|
```bash
|
|
python3 -m unittest discover -s integration -v
|
|
```
|
|
|
|
The HTTPS clone URL corresponds to
|
|
`git@dandaedre.com:Ravenous/ravenous_roll20.git` and avoids requiring an SSH key
|
|
for this CI test. If authentication is required, configure Git credentials on
|
|
the agent; prompts are disabled. Clone failures fail the build. Disable the
|
|
`RUN_CLONE_TEST` build parameter for an offline unit-test-only run.
|
|
|
|
This pipeline only checks out and tests. It does not publish artifacts, send
|
|
checks, push commits, or deploy files. Test results appear in the console log.
|