@@ -57,19 +57,21 @@ public static Commit FindCommitBranchWasBranchedFrom([NotNull] this Branch branc
57
57
throw new ArgumentNullException ( "branch" ) ;
58
58
}
59
59
60
- if ( branch . Tip == null )
61
- {
62
- throw new ArgumentException ( String . Format ( missingTipFormat , branch . Name ) ) ;
63
- }
64
-
65
60
using ( Logger . IndentLog ( "Finding branch source" ) )
66
61
{
62
+ if ( branch . Tip == null )
63
+ {
64
+ Logger . WriteWarning ( String . Format ( missingTipFormat , branch . Name ) ) ;
65
+ return null ;
66
+ }
67
+
67
68
var otherBranches = repository . Branches . Except ( excludedBranches ) . Where ( b => IsSameBranch ( branch , b ) ) . ToList ( ) ;
68
69
var mergeBases = otherBranches . Select ( b =>
69
70
{
70
71
if ( b . Tip == null )
71
72
{
72
- throw new InvalidOperationException ( String . Format ( missingTipFormat , b . Name ) ) ;
73
+ Logger . WriteWarning ( String . Format ( missingTipFormat , b . Name ) ) ;
74
+ return null ;
73
75
}
74
76
75
77
var otherCommit = b . Tip ;
@@ -90,12 +92,17 @@ static bool IsSameBranch(Branch branch, Branch b)
90
92
return ( b . IsRemote ? b . Name . Replace ( b . Remote . Name + "/" , string . Empty ) : b . Name ) != branch . Name ;
91
93
}
92
94
93
- public static IEnumerable < Branch > GetBranchesContainingCommit ( this Commit commit , IRepository repository , bool onlyTrackedBranches )
95
+ public static IEnumerable < Branch > GetBranchesContainingCommit ( [ NotNull ] this Commit commit , IRepository repository , bool onlyTrackedBranches )
94
96
{
97
+ if ( commit == null )
98
+ {
99
+ throw new ArgumentNullException ( "commit" ) ;
100
+ }
101
+
95
102
var directBranchHasBeenFound = false ;
96
103
foreach ( var branch in repository . Branches )
97
104
{
98
- if ( branch . Tip . Sha != commit . Sha || ( onlyTrackedBranches && ! branch . IsTracking ) )
105
+ if ( branch . Tip != null && branch . Tip . Sha != commit . Sha || ( onlyTrackedBranches && ! branch . IsTracking ) )
99
106
{
100
107
continue ;
101
108
}
0 commit comments