TfsCmdlets icon indicating copy to clipboard operation
TfsCmdlets copied to clipboard

Add support for listing Git repositories in the Recycle Bin

Open Copilot opened this issue 9 months ago • 0 comments

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 IncludeRecycleBin SwitchParameter to the Get-TfsGitRepository cmdlet
  • 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:

  • GitRepository objects for active repositories
  • GitDeletedRepository objects 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 -IncludeParent and -Default parameters
  • 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:


💡 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.

Copilot avatar Jun 06 '25 03:06 Copilot