@@ -13,6 +13,8 @@ public class ReferenceName : IEquatable<ReferenceName?>, IComparable<ReferenceNa
13
13
private const string TagPrefix = "refs/tags/" ;
14
14
private const string PullRequestPrefix1 = "refs/pull/" ;
15
15
private const string PullRequestPrefix2 = "refs/pull-requests/" ;
16
+ private const string RemotePullRequestPrefix1 = "refs/remotes/pull/" ;
17
+ private const string RemotePullRequestPrefix2 = "refs/remotes/pull-requests/" ;
16
18
17
19
public ReferenceName ( string canonical )
18
20
{
@@ -23,7 +25,10 @@ public ReferenceName(string canonical)
23
25
IsBranch = IsPrefixedBy ( Canonical , LocalBranchPrefix ) ;
24
26
IsRemoteBranch = IsPrefixedBy ( Canonical , RemoteTrackingBranchPrefix ) ;
25
27
IsTag = IsPrefixedBy ( Canonical , TagPrefix ) ;
26
- IsPullRequest = IsPrefixedBy ( Canonical , PullRequestPrefix1 ) || IsPrefixedBy ( Canonical , PullRequestPrefix2 ) ;
28
+ IsPullRequest = IsPrefixedBy ( Canonical , PullRequestPrefix1 )
29
+ || IsPrefixedBy ( Canonical , PullRequestPrefix2 )
30
+ || IsPrefixedBy ( Canonical , RemotePullRequestPrefix1 )
31
+ || IsPrefixedBy ( Canonical , RemotePullRequestPrefix2 ) ;
27
32
}
28
33
29
34
public static ReferenceName Parse ( string canonicalName )
@@ -75,9 +80,17 @@ private string RemoveRemote()
75
80
{
76
81
var isRemote = IsPrefixedBy ( Canonical , RemoteTrackingBranchPrefix ) ;
77
82
78
- return isRemote
79
- ? Friendly . Substring ( Friendly . IndexOf ( "/" , StringComparison . Ordinal ) + 1 )
80
- : Friendly ;
83
+ if ( isRemote )
84
+ {
85
+ var isPullRequest = IsPrefixedBy ( Canonical , RemotePullRequestPrefix1 )
86
+ || IsPrefixedBy ( Canonical , RemotePullRequestPrefix2 ) ;
87
+
88
+ if ( ! isPullRequest )
89
+ return Friendly . Substring ( Friendly . IndexOf ( "/" , StringComparison . Ordinal ) + 1 ) ;
90
+ }
91
+
92
+ return Friendly ;
81
93
}
94
+
82
95
private static bool IsPrefixedBy ( string input , string prefix ) => input . StartsWith ( prefix , StringComparison . Ordinal ) ;
83
96
}
0 commit comments