Добавить Cursor rules, init-cursor и скрипты настройки git remotes.

Канонический источник для клонирования в $HOME\CursorRules на новых ПК.
This commit is contained in:
2026-06-18 09:51:39 +10:00
parent ff87be5824
commit 3adf0c5211
18 changed files with 599 additions and 1 deletions
+97
View File
@@ -0,0 +1,97 @@
#Requires -Version 5.1
<#
.SYNOPSIS
Стандартные git remote: home, kalinamall, github.
.EXAMPLE
cd C:\Users\papat\Projects\MyRepo
& "$HOME\CursorRules\scripts\Set-GitRemotes.ps1"
#>
[CmdletBinding()]
param(
[string]$Owner = 'PapaTramp',
[string]$GithubOrg = 'PTah',
[string]$Repo = '',
[switch]$SkipKalinamall,
[switch]$WhatIf
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
function Write-Step([string]$Message) { Write-Host "[*] $Message" -ForegroundColor Cyan }
function Write-Ok([string]$Message) { Write-Host "[+] $Message" -ForegroundColor Green }
function Test-GitRepo {
git rev-parse --is-inside-work-tree 2>$null | Out-Null
if ($LASTEXITCODE -ne 0) {
throw 'Run inside a git repository or pass -Repo.'
}
}
function Get-RepoName {
param([string]$Name)
if ($Name) { return $Name }
return (Split-Path -Leaf (git rev-parse --show-toplevel))
}
function Set-Remote {
param(
[string]$Name,
[string]$Url
)
$existing = git remote 2>$null
$has = $existing -contains $Name
if ($WhatIf) {
Write-Step "WhatIf: remote $Name -> $Url"
return
}
if ($has) {
$current = (git remote get-url $Name 2>$null).Trim()
if ($current -eq $Url) {
Write-Ok "remote $Name OK"
return
}
git remote set-url $Name $Url
Write-Ok "remote $Name updated -> $Url"
return
}
$legacy = @{
home = @('gitea', 'papatramp', 'origin-home')
github = @('origin')
kalinamall = @('gitea-kalinamall', 'kalina')
}
foreach ($old in $legacy[$Name]) {
if ($existing -contains $old) {
git remote rename $old $Name
git remote set-url $Name $Url
Write-Ok "remote $old renamed to $Name -> $Url"
return
}
}
git remote add $Name $Url
Write-Ok "remote $Name added -> $Url"
}
Test-GitRepo
$repoName = Get-RepoName -Name $Repo
$homeUrl = "ssh://git@git.papatramp.lan:2222/${Owner}/${repoName}.git"
$kalinamallUrl = "ssh://git@git.kalinamall.lan:2222/${Owner}/${repoName}.git"
$githubUrl = "git@github.com:${GithubOrg}/${repoName}.git"
Write-Step "Repo: $repoName"
Set-Remote -Name 'home' -Url $homeUrl
Set-Remote -Name 'github' -Url $githubUrl
if (-not $SkipKalinamall) {
Set-Remote -Name 'kalinamall' -Url $kalinamallUrl
}
Write-Host ''
Write-Host 'Remotes:' -ForegroundColor Magenta
git remote -v