Home > Software engineering >  TF history - prompt user
TF history - prompt user

Time:08-26

I want to prompt only username/author of last changeset. It is possible?

tf history . /r /noprompt /stopafter:1

CodePudding user response:

I don't think we can prompt only the username/author of the latest changeset by running the History command. Basically, the command will list the Changeset, User,Dateand Comment. See enter image description here

However you can try to write a script to run the command and retrieve the Author only if possible.

Besides, you can also achieve that by calling the Get Changesets REST API in a script.

Below PowerShell script for your reference:

$collectionurl = "https://xxx/DefaultCollection"
$project = "ProjectName"
$user = ""
$token = "PAT"

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$changeseturl = "$collectionurl/_apis/tfvc/changesets?searchCriteria.itemPath=$/$project&api-version=6.0"

$result = (Invoke-RestMethod -Uri $changeseturl -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}).value | Select -first 1  

Write-host "The last changeset author is:" $result.author.displayName
  • Related