StartAutomating / ugit

Updated Git: A powerful PowerShell wrapper for git that lets you extend git, automate multiple repos, and output git as objects.
https://ugit.start-automating.com
MIT License
72 stars 6 forks source link

ugit properties should be aware if the folder is a git folder. #198

Closed trackd closed 10 months ago

trackd commented 10 months ago

ugit should not assume that all files are git files. either it should look for .git folders and/or configurable paths where the properties are active.

Example

Get-Item -Path C:\Windows\notepad.exe | Select-Object *
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository
WARNING: 'C:\Windows' is not a git repository

Get-Item -Path C:\Windows\notepad.exe | gm -Type AliasProperty,ScriptMethod,ScriptProperty

   TypeName: System.IO.FileInfo

Name          MemberType     Definition
----          ----------     ----------
Changes       AliasProperty  Changes = GitChanges
Diff          AliasProperty  Diff = GitDiff
GitDifference AliasProperty  GitDifference = GitDiff
GitHistory    AliasProperty  GitHistory = GitChanges
GitLog        AliasProperty  GitLog = GitLogs
HasChanged    AliasProperty  HasChanged = GitDirty
HasChanges    AliasProperty  HasChanges = GitDirty
History       AliasProperty  History = GitChanges
IsUnstaged    AliasProperty  IsUnstaged = GitDirty
Logs          AliasProperty  Logs = GitLogs
Target        AliasProperty  Target = LinkTarget
GitChanges    ScriptMethod   System.Object GitChanges();
BaseName      ScriptProperty System.Object BaseName {get=if ($this.Extension.Length -gt 0){$this.Name.Remove($this.Name.Length - $this.Extension.Length)}else{$this.Name…
GitDiff       ScriptProperty System.Object GitDiff {get=Push-Location $this.Directory…
GitDirty      ScriptProperty System.Object GitDirty {get=Push-Location $this.Directory…
GitLogs       ScriptProperty System.Object GitLogs {get=Push-Location $this.Directory…
VersionInfo   ScriptProperty System.Object VersionInfo {get=[System.Diagnostics.FileVersionInfo]::GetVersionInfo($this.FullName);}
StartAutomating commented 10 months ago

@trackd I hear what you're asking.

Unfortunately, it's there's not a way to only apply type extensions to files if they are in a git directory (and there are benefits to being able to get file-related info from git).

What I can do is this: remove the warnings.

Sound acceptable?