TfsCmdlets
TfsCmdlets copied to clipboard
Add Undo-TfsGitRepositoryRemoval cmdlet for restoring repositories from Recycle Bin
This PR adds support for restoring Git repositories from the Recycle Bin through a new Undo-TfsGitRepositoryRemoval cmdlet, similar to the existing Undo-TfsTeamProjectRemoval functionality.
What's Added
-
New Cmdlet:
Undo-TfsGitRepositoryRemovalthat restores deleted Git repositories - API Integration: Uses Azure DevOps REST API v7.1 endpoint for repository restoration
- Multiple Input Types: Supports GitRepository objects, GitRepositoryRef objects, and repository GUIDs
- Basic Tests: Unit tests following the existing test patterns
Usage Examples
# Restore by repository ID
Undo-TfsGitRepositoryRemoval -Repository "5db56f26-27b9-44a1-b906-814d03982840" -Project "MyProject"
# Restore by GitRepository object (piped from another command)
$deletedRepo | Undo-TfsGitRepositoryRemoval
# Use -WhatIf to preview the operation
Undo-TfsGitRepositoryRemoval -Repository $repoId -Project $project -WhatIf
Implementation Details
-
Follows Established Patterns: Uses the same structure and approach as
Undo-TfsTeamProjectRemoval -
REST API Call:
PATCH /{project}/_apis/git/repositories/{repositoryId}/recycleBinwith{"deleted": false} -
Safety Features: Includes
ShouldProcesssupport for confirmation prompts - Error Handling: Meaningful error messages for invalid inputs
- Minimal Changes: 126 lines added, 0 lines deleted
API Reference
The implementation follows the Azure DevOps REST API documentation for restoring repositories from the recycle bin.
Fixes #242.
[!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 TfsCmdlets.sln(http block)http://www.microsoft.com:80/pkiops/crl/Microsoft%20Public%20RSA%20Timestamping%20CA%202020.crl
- Triggering command:
dotnet build 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.