File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -381,6 +381,31 @@ jobs:
381381 echo "✅ init correctly refuses to remove last platform"
382382 rm -rf "$INIT_DIR"
383383
384+ - name : " Test: init --force skips git repo check"
385+ shell : bash
386+ run : |
387+ INIT_DIR=$(mktemp -d)
388+ cd "$INIT_DIR"
389+ # Do NOT run git init - this is intentionally not a git repo
390+
391+ # Without --force, should fail
392+ if $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --current-platform-only 2>&1; then
393+ echo "ERROR: init should fail without --force in non-git directory"
394+ exit 1
395+ fi
396+
397+ # With --force, should succeed
398+ $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --current-platform-only --force
399+
400+ # Verify files were created
401+ if [ ! -f ".rnr/config.yaml" ]; then
402+ echo "ERROR: .rnr/config.yaml not created with --force"
403+ exit 1
404+ fi
405+
406+ echo "✅ init --force correctly skips git repo check"
407+ rm -rf "$INIT_DIR"
408+
384409 # ==================== Error Cases ====================
385410
386411 - name : " Test: nonexistent task (should fail)"
Original file line number Diff line number Diff line change @@ -51,4 +51,8 @@ pub struct InitArgs {
5151 /// Show currently configured platforms
5252 #[ arg( long) ]
5353 pub show_platforms : bool ,
54+
55+ /// Skip git repository root check
56+ #[ arg( long) ]
57+ pub force : bool ,
5458}
Original file line number Diff line number Diff line change @@ -38,12 +38,12 @@ pub fn run(args: &InitArgs) -> Result<()> {
3838 return Ok ( ( ) ) ;
3939 }
4040
41- // Error if not at git repo root
42- if !is_git_repo_root ( ) ? {
41+ // Error if not at git repo root (unless --force is used)
42+ if !args . force && ! is_git_repo_root ( ) ? {
4343 bail ! (
4444 "This directory does not appear to be a git repository root.\n \
45- rnr must be initialized at the root of a git repository.\n \
46- Please run 'rnr init' from the directory containing your .git folder."
45+ rnr is typically initialized at the root of a git repository.\n \
46+ Use --force to initialize anyway, or run from the directory containing your .git folder."
4747 ) ;
4848 }
4949
You can’t perform that action at this time.
0 commit comments