This commit is contained in:
2026-05-10 01:16:10 +00:00
parent d6bf0293ba
commit 43a260191c
3 changed files with 73 additions and 1 deletions
+25 -1
View File
@@ -547,7 +547,7 @@ function git-main-branch {
}
Write-Error 'Could not determine main branch.'
return 1
return
}
function git-update-main {
@@ -560,6 +560,16 @@ function git-update-main {
Invoke-RawGit pull --ff-only
}
function git-fetch-main {
param([string]$MainBranch)
if (-not $MainBranch) { $MainBranch = git-main-branch | Select-Object -First 1 }
if (-not $MainBranch) { return }
Invoke-RawGit fetch origin "+refs/heads/${MainBranch}:refs/remotes/origin/${MainBranch}"
if ($LASTEXITCODE -ne 0) { return }
Write-Output $MainBranch
}
function br {
param([Parameter(Mandatory = $true)][string]$Branch)
if (-not (Test-GitCleanWorktree)) { return 1 }
@@ -600,6 +610,20 @@ function bru {
Invoke-RawGit rebase $mainBranch
}
function brup {
$currentBranch = Invoke-RawGit symbolic-ref --quiet --short HEAD 2>$null
if ($LASTEXITCODE -ne 0 -or -not $currentBranch) {
Write-Error 'Could not determine current branch.'
return 1
}
if (-not (Test-GitCleanWorktree)) { return 1 }
$mainBranch = git-fetch-main | Select-Object -First 1
if (-not $mainBranch) { return 1 }
Invoke-RawGit merge "refs/remotes/origin/$mainBranch"
}
function git-env {
foreach ($cmd in @('add', 'bisect', 'branch', 'checkout', 'clone', 'commit', 'diff', 'fetch', 'grep', 'init', 'log', 'merge', 'pull', 'push', 'rebase', 'reset', 'restore', 'show', 'stash', 'tag')) {
$name = $cmd