Support running from any subdirectory of a git repo#12
Merged
Conversation
97631a3 to
9661b7b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Allow
contagentto be invoked from any subdirectory within a git repository, not just the root. Previously, running from a subdirectory would fail because the git server validation looked for.gitin the current directory rather than walking up to the repo root.Key changes:
FindRootas a public function in thegitpackage, usinggit rev-parse --show-toplevelto locate the repo rootmain.gocallsFindRootupfront, then passes the resolved root to bothNewServerandCreateArchiveconfig.WorkingDir + relPathso the container starts at the equivalent location — keeping the git root path stable in the container.gitexistence check fromNewServer(validation now happens viaFindRootin the caller)Why
Working in monorepos was difficult because
contagentrequired being at the repo root. Users had tocdto the root before every invocation, breaking workflows where tools are run from within a package or service subdirectory.How to Test
Prerequisites:
go build -o contagent .Steps:
cdinto a subdirectory (e.g.,cd src/)contagentfrom there:/path/to/contagent <your-command>/app/src)/appinside the containerRun the test suite:
go test ./...