How can I find the root folder of a given subversion working copy

后端 未结 8 739
暗喜
暗喜 2020-12-09 15:44

Quite often I\'m sitting in the middle of a subversion working copy, and I want to do a quick svn status to find out what changes I have made since the last che

相关标签:
8条回答
  • 2020-12-09 16:30

    If you use git-svn as your Subversion client, then you can interact transparently with a Subversion repository using Git commands locally. Git automatically shows you pending across the whole repository when you use commands like git status anywhere in the tree.

    0 讨论(0)
  • 2020-12-09 16:38

    Here is my solution, which is a hybrid of various solutions put here. It is written in PowerShell, as I needed it for a PowerShell module I am writing.

    <#
        This command outputs the top-most parent of the current folder.
    
        If the current folder is not under svn revision control,
        it will recurse up one level, and try again.
    
        It stops at the root folder on the current drive.
        If the current folder's drive's root folder is not under svn revision control,
        it will throw an exception "No SVN Root Directory found."
    #>
    function Get-SvnRootDirectory {
        $currentDirectory = Get-Location
    
        do {
            $output = $(svn info $currentDirectory 2> $null)
            $output = $output | findstr /C:"Working Copy Root Path:"
            if ($LASTEXITCODE -eq 0)
            {
                break;
            }
            # if (Test-Path -PathType Container -Path $currentDirectory)
            # {
            #     throw "No SVN Root Directory found."
            # }
            $currentDirectory = Split-Path -Path $currentDirectory -Parent
            if ([string]::IsNullOrWhiteSpace($currentDirectory))
            {
                throw "No SVN Root Directory found."
            }
        }
        while ($true)
    
        $output -match "Working Copy Root Path: (?<Group>.*)$" | Out-Null
        return $Matches.Group
    }
    
    0 讨论(0)
提交回复
热议问题