Suggestion: PSProvider for working with Git
Default PSProviders in PowerShell are the followings:
> Get-PSProvider
Name Capabilities Drives
---- ------------ ------
Registry ShouldProcess, Transactions {HKLM, HKCU}
Alias ShouldProcess {Alias}
Environment ShouldProcess {Env}
FileSystem Filter, ShouldProcess, Credentials {C, D, E, F...}
Function ShouldProcess {Function}
Variable ShouldProcess {Variable}
I thought it would make sense to have one for working with Git repositories, so that you can do, for example:
Get-ChildItem Git:MyRepo\src\*
and other Git operations with standard PS cmdlets.
Can you give some more examples of git actions which you can imagine mapping to a provider?
For instance, how would you imagine handling the core 6: clone status add commit push pull
In my head, I immediately thought git clone would map to New-PSDrive ... but that already clashes with your example :wink:
i had considered this too (once i saw add-item remove-item) but after giving it some thought i realized it wouldnt really work out too well in the end
I don't think there is an intuitive way to do the main operations. Now that I think more about it I think a PSProvider would be better suited for managing the Git repositories on your computer, rather than Git operations themselves. For example the Git: drive can be your central point for registering and accessing Git repositories on your computer, or on your GitHub account. I think it can work well with Git cmdlets. For example I can imagine the following scenario:
cd GitHub:PoshCode/PSGit
dir # list files
Get-Commit # list commits
Open-Commit a6eb714 # open commit in GitHub
Git-Clone . C:\GitHub -register
cd Git:\
dir # list registered repos
dir -directory | where { $_.Remote -eq PoshCode/PSGit }
Difference between using the repository from file system vs Git: drive is that when querying files in the Git: drive you will get get-specific properties, such as SHA, LastModifiedBy, LastCommitDate, History, Lines, IsIgnored, RemotePath, etc.
Oh, well in that case, you'll be happy to hear that you don't need a git drive to get stuff like that when you query files ... we can detect you're in a git folder and give you stuff like that on your Get-ChildItem output automatically, without needing to register them.
yeah, if you look there is a GCI Proxy branch (currently a PR) that shows the change/stage state
That's great to know. Thank you guys.