src/Models/FileChange.ps1
|
# FileChange — Un archivo cambiado en working tree o entre dos branches. # Status válidos: # Working tree (Quick Changes): M (modified), A (added), D (deleted), '?' (untracked) # Compare (entre branches): ~ (modified), + (added), - (deleted) class FileChange { [string] $State # ver header [string] $Path # relativo al repo root [int] $Adds [int] $Dels FileChange() { } FileChange([string]$state, [string]$path) { $this.State = $state $this.Path = $path } FileChange([string]$state, [string]$path, [int]$adds, [int]$dels) { $this.State = $state $this.Path = $path $this.Adds = $adds $this.Dels = $dels } [string] FileName() { return ($this.Path -split '[/\\]')[-1] } [string] DirName() { $parts = $this.Path -split '[/\\]' if ($parts.Count -le 1) { return '' } return ($parts[0..($parts.Count - 2)] -join '/') } [string] ToString() { return "[$($this.State)] $($this.Path)" } } |