Add support for listing Git repositories in the Recycle Bin
This PR adds support for retrieving Git repositories from the Recycle Bin to the Get-TfsGitRepository cmdlet by introducing a new -IncludeRecycleBin parameter.
Changes Made
Core Implementation
-
Added
IncludeRecycleBinSwitchParameter to theGet-TfsGitRepositorycmdlet -
Enhanced controller logic to call
GetRecycleBinRepositoriesAsync()when the parameter is specified -
Integrated recycle bin search into all existing repository lookup patterns:
- Exact name matching
- GUID-based lookup
- Wildcard pattern matching
- Multiple repository inputs
API Integration
The implementation leverages the existing GitHttpClient.GetRecycleBinRepositoriesAsync() method, which calls the Azure DevOps REST API endpoint:
GET https://dev.azure.com/{organization}/{project}/_apis/git/recycleBin/repositories?api-version=7.1
Usage Examples
Get all repositories including those in the recycle bin:
Get-TfsGitRepository -Repository '*' -IncludeRecycleBin -Project 'MyProject'
Find a specific deleted repository:
Get-TfsGitRepository -Repository 'DeletedRepo' -IncludeRecycleBin -Project 'MyProject'
Find deleted repositories matching a pattern:
Get-TfsGitRepository -Repository 'Old*' -IncludeRecycleBin -Project 'MyProject'
Output Types
When -IncludeRecycleBin is used, the cmdlet returns:
-
GitRepositoryobjects for active repositories -
GitDeletedRepositoryobjects for deleted repositories from the recycle bin
The GitDeletedRepository objects include properties like Id, Name, ProjectReference, DeletedBy, CreatedDate, and DeletedDate.
Testing and Documentation
- Comprehensive test coverage for all parameter combinations and edge cases
- Complete documentation with usage examples and API references
- Backward compatibility maintained - existing functionality unchanged when parameter not used
Key Features
- ✅ Efficient implementation: Single API call for recycle bin data per repository search
- ✅ Wildcard support: Full pattern matching for deleted repositories
- ✅ Parameter compatibility: Works seamlessly with existing
-IncludeParentand-Defaultparameters - ✅ Multiple input support: Handles arrays of repository names/patterns
- ✅ Error handling: Graceful handling of API failures and missing repositories
Fixes #241.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
http://www.microsoft.com:80/pkiops/crl/Microsoft%20Identity%20Verification%20Root%20Certificate%20Authority%202020.crl
- Triggering command:
dotnet build CSharp/TfsCmdlets.sln(http block)http://www.microsoft.com:80/pkiops/crl/Microsoft%20Public%20RSA%20Timestamping%20CA%202020.crl
- Triggering command:
dotnet build CSharp/TfsCmdlets.sln(http block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.