Azure devops 查找回购分支令牌

Azure devops 查找回购分支令牌,azure-devops,azure-devops-rest-api,Azure Devops,Azure Devops Rest Api,在使用存储库的安全API时,使用从分支的“人类”名称派生的字母数字标识符引用各个分支 此标识符是令牌的最后一部分。例如,主分支的标识符总是6D00610073007400065007200。这不是后端系统分配的GUID,而是一个计算值 我查阅了API文档,没有找到任何方法来查找此标识符 只是想知道我是不是错过了什么或者找错了地方?有人知道是否有地方可以找到这些信息吗?这是一个在PowerShell中编写的粗略函数,但它可以将分支名称转换为必需的十六进制代码 Function get-AzDoBr

在使用存储库的安全API时,使用从分支的“人类”名称派生的字母数字标识符引用各个分支

此标识符是令牌的最后一部分。例如,主分支的标识符总是
6D00610073007400065007200
。这不是后端系统分配的GUID,而是一个计算值

我查阅了API文档,没有找到任何方法来查找此标识符


只是想知道我是不是错过了什么或者找错了地方?有人知道是否有地方可以找到这些信息吗?

这是一个在PowerShell中编写的粗略函数,但它可以将分支名称转换为必需的十六进制代码

Function get-AzDoBranchTokenFromName {  
    <#
    .SYNOPSIS
    Convert branch name to token

    .DESCRIPTION
    Azure DevOps Services security stores Access Control Lists and other items
    for Branches using a alphanumeric identifier derived from the text name of
    the branch.  This function will convert the name, like "master", into the 
    appropriate string, like 6d0061007300740065007200

    .PARAMETER branchName
    The human name of the git repository branch

    .EXAMPLE
    get-AzDoBranchTokenFromName -branchName "master"

    .NOTES
    The fun part is trying to go backwards (from hex to string).  Need to 
    work on that yet. 
    #>

    param(  
        # The sting you wish to Convert
        [Parameter(Mandatory=$true)]
        [string]
        $branchName   
    )
    # convert a string to an array of bytes    
    $bytes = [System.Text.Encoding]::Unicode.GetBytes($branchName)    
    # create a new variable twice as long as $bytes
    $Hex = [System.Text.StringBuilder]::new($Bytes.Length * 2)    
    # take each byte, format it as two hex characters and shove it into $Hex
    ForEach ($byte in $bytes) {      
        if ($byte -eq 47) {
            #Write-Output "YATZEE!!!!"
            $Hex.Append("/") | Out-Null
        }else{
        $Hex.AppendFormat("{0:x2}", $byte) | Out-Null    
        }
    }
    # convert $Hex back to a string    
    $Hex.ToString()
}
函数get AzDoBranchTokenFromName{
参数(
#你想转化的毒刺
[参数(必需=$true)]
[字符串]
$branchName
)
#将字符串转换为字节数组
$bytes=[System.Text.Encoding]::Unicode.GetBytes($branchName)
#创建一个新变量,其长度为$bytes的两倍
$Hex=[System.Text.StringBuilder]::新($Bytes.Length*2)
#取每个字节,将其格式化为两个十六进制字符,并将其转换为$hex
ForEach($字节中的字节){
if($byte-eq 47){
#写入输出“YATZEE!!!!”
$Hex.Append(“/”)| Out Null
}否则{
$Hex.AppendFormat(“{0:x2},$byte)| Out Null
}
}
#将$Hex转换回字符串
$Hex.ToString()
}