PS /> git branch --format='{"name":"%(refname:lstrip=2)"}' --list %(refname:lstrip=2)
{"name":"main"}
{"name":"feature-branch-a"}
{"name":"feature-branch-b"}
,... PS /> git branch --format='{"name":"%(refname:lstrip=2)","isMainBranch":'"$(if [[ $(git symbolic-ref --short HEAD) == "main" ]]; then echo true; else echo false; fi)"' }' --list ParserError:
Line |
1 | … --format='{"name":"%(refname:lstrip=2)","isMainBranch":'"$(if [[ $(gi …
| ~
| Missing '(' after 'if' in if statement. '"`$(if [[ `$
{"name":"main","isMainBranch":$(if [[ $(git symbolic-ref --short HEAD) == main ]]; then echo true; else echo false; fi) }
{"name":"feature-branch-a","isMainBranch":$(if [[ $(git symbolic-ref --short HEAD) == main ]]; then echo true; else echo false; fi) }
{"name":"feature-branch-b","isMainBranch":$(if [[ $(git symbolic-ref --short HEAD) == main ]]; then echo true; else echo false; fi) } $branches = git branch | ForEach-Object {
$default = $false
$activeBranch = git symbolic-ref --short HEAD
$currentBranch = ($_.Replace("* ", " ")).Trim()
if ($currentBranch -eq $activeBranch) {
$default = $true
}
@{
name = $currentBranch
isMainBranch = $default
} | ConvertTo-Json
} | ConvertFrom-Json
برچسب:
نویسنده: دانلودی