cake
                                
                                 cake copied to clipboard
                                
                                    cake copied to clipboard
                            
                            
                            
                        [Proposal] TFBuild.PullRequest API
I wrote a build script today that had to check SYSTEM_PULLREQUEST_PULLREQUESTID to see if the current build was a pull request and to form a version string.
This seems like it might be a nice way to bring the TFBuild API to parity with the AppVeyor API. I'm willing to contribute the PR! 😃
Proposal
Source: https://docs.microsoft.com/vsts/build-release/concepts/definitions/build/variables#systempullrequestisfork
namespace Cake.Common.Build.TFBuild.Data
{
    public sealed class TFBuildEnvironmentInfo : TFInfo
    {
+       /// <summary>
+       /// Gets TF pull request info, or <see langword="null"/> if the current build
+       /// is not for a pull request.
+       /// </summary>
+       public TFBuildPullRequestInfo PullRequest { get; }
    }
+   public sealed class TFBuildPullRequestInfo : TFInfo
+   {
+       public bool IsFork => GetEnvironmentBool("SYSTEM_PULLREQUEST_ISFORK");
+
+       public int Id => GetEnvironmentInteger("SYSTEM_PULLREQUEST_PULLREQUESTID");
+
+       public int Number => GetEnvironmentInteger("SYSTEM_PULLREQUEST_PULLREQUESTNUMBER");
+
+       public string SourceBranch => GetEnvironmentInteger("SYSTEM_PULLREQUEST_SOURCEBRANCH");
+
+       public string SourceRepositoryUri => GetEnvironmentInteger("SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI");
+
+       public string TargetBranch => GetEnvironmentInteger("SYSTEM_PULLREQUEST_TARGETBRANCH");
+   }
}
Questions
- 
You have IsPullRequestfor AppVeyor. Which is preferable?- TFBuild.Environment.PullRequest == null
- TFBuild.Environment.IsPullRequest
- TFBuild.Environment.PullRequest.IsPullRequest
 
- 
To decide whether PullRequest == nullorIsPullRequestshould be true, we could check whetherBUILD_REASONisPullRequest. However, if possible, it might be most flexible to check for the presence or absence ofSYSTEM_PULLREQUEST_PULLREQUESTID.
Sure sounds like a good addition
- IsPullRequest
- Unsure, SYSTEM_PULLREQUEST_PULLREQUESTID feels more correct, but not read docs, what do they say?