开发者

TFS: How can I select one of my previous commit comments?

开发者 https://www.devze.com 2023-02-25 08:35 出处:网络
Often I\'d like to use a previous commit comment (and edit e.g. just one word) for check-in. I\'m used to eclipse, where this fe开发者_Python百科ature works quite well.

Often I'd like to use a previous commit comment (and edit e.g. just one word) for check-in.

I'm used to eclipse, where this fe开发者_Python百科ature works quite well.

Is it also available for TFS? I didn't find it yet (despite quick Web search), am I blind? (I'm currently using TFS 2010 with VisualStudio 2010)

Best regards, Mayoares


I don't think there is anything in VS to help here (except cut and paste via change history).

However a little PowerShell with PSCX (PowerShell community Extensions) and the TFS PowerToys PowerShell snapin will do this, with the current folder set to the solution root:

(Get-TfsItemHistory . -recurse -stop 1).Comment | Set-Clipboard

will put the comment in the clipboard. Using the NuGet powershell session in TFS, this could likely be automated completely (left as exercise).


Not to take away from @Richard for providing the crux to the solution--I have already upvoted his answer--but there is just a bit more to say here.

The OP was just slightly ambiguous: the title leaned toward the capability of selecting some recent commit message while the body was more suggesting to retrieve the most recent commit message. Richard addressed the latter perfectly, but I think it is worth commenting on the former as well.

Consider this function, which uses the same Get-TfsItemHistory from TFS 2013 Power Tools that Richard mentioned:

function Get-TfsComment([string]$pattern = ".*", [string]$Path = ".")
{
    Get-TfsItemHistory $Path -Recurse | ? { $_.Comment -match $pattern }
}

With that in place try:

# Get all comments
Get-TfsComment

# Get 10 latest comments
Get-TfsComment | Select -First 10

# Get all comments containing "bug" and "fix"
Get-TfsComment "bug.*fix"

# Get all comments in your tests folder containing "support"
Get-TfsComment -path .\tests -pattern support

The output of this function produces a collection of Microsoft.TeamFoundation.VersionControl.Client.Changeset objects; the list of default properties it displays are typically all you need:

Changes Owner               CreationDa Comment
   etId                             te
------- -----               ---------- -------
   1187 MYDOMAIN\fred        3/13/2014 Bug fixes for xyz...
   1118 MYDOMAIN\wilma        3/7/2014 New features 139 and 448
   1076 MYDOMAIN\barney      2/28/2014 Who remembers this...?
. . .

(Note that if you pipe the output to FormatTable -AutoSize that will take care of the poorly optimized line-wrap in the column headers.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号