Overview
The repository resolution module provides functions for parsing repo names from task messages, validating they belong to an allowed GitHub org, and cloning them into temporary workspaces. This enables Magpie to work across multiple repositories in an organization.Configuration
RepoConfig
The GitHub organization that all repositories must belong to.Used to validate that parsed repo names are within the allowed scope. Case-sensitive.
ResolvedRepo
ResolvedRepo owns the temporary directory — when this value is dropped, the clone is automatically deleted.
Functions
Parse the repo name from a task message.Parameters:
message- The task message to parse
Some(String)- Repo name (without org prefix)None- No recognizable repo pattern found
"fix login bug in api-service"→Some("api-service")"fix bug repo api-service"→Some("api-service")"fix bug in myorg/api-service"→Some("api-service")(strips org prefix)
- Pass 1: Looks for
"repo <name>"pattern - Pass 2: Looks for
"in <name>"pattern (skips noise words)
the, a, an, this, that, my, our, your, its, some, any, code, project, codebase, app, applicationExample:Validate that a repo belongs to the allowed org.Parameters:
full_name- Fully-qualified repo name (e.g.,"myorg/api-service")org- Expected organization name
Ok(())- Repo belongs to the orgErr(_)- Repo doesn’t belong to org or validation failed
- Performs string-prefix check on
"{org}/" - Verifies repo part after slash is non-empty
- Case-sensitive match (though GitHub orgs are case-insensitive, this enforces config safety)
Clone
org/repo into a temp directory using gh repo clone.Parameters:repo_name- Repository name (without org prefix)org- GitHub organization name
Ok(ResolvedRepo)- Cloned repo with temp directory ownershipErr(_)- If cloning fails (network error, repo doesn’t exist, auth issues)
ghCLI must be installed and authenticated- User must have access to the repository
ResolvedRepo owns the temp directory. When dropped, the directory is automatically cleaned up.Example:Complete Example
Pattern Matching Details
Valid Repo Names
A valid repo name must:- Be at least 1 character long
- Start with an alphanumeric character
- Contain only alphanumeric characters, hyphens, underscores, or dots
Message Parsing Examples
Usage in Pipeline
The repo resolution functions are used during pipeline setup:Security Considerations
- Org Validation: Always validate the org before cloning to prevent access to unauthorized repositories
- Case Sensitivity: Org matching is case-sensitive by design for config safety
- Temp Directory Cleanup:
ResolvedRepoautomatically cleans up temp directories on drop to prevent disk space leaks - Auth Required:
gh repo clonerequires GitHub CLI authentication