PoshCode / PSGit

A PowerShell implementation of Git, mapping git commands to Verb-Noun and objects.
105 stars 15 forks source link

Suggestion: PSProvider for working with Git #47

Open omidkrad opened 9 years ago

omidkrad commented 9 years ago

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.

Jaykul commented 9 years ago

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:

jrich523 commented 9 years ago

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

omidkrad commented 9 years ago

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.

Jaykul commented 9 years ago

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.

jrich523 commented 9 years ago

yeah, if you look there is a GCI Proxy branch (currently a PR) that shows the change/stage state

omidkrad commented 9 years ago

That's great to know. Thank you guys.