@@ -25,15 +25,19 @@ public SourceLinkTests(ITestOutputHelper log)
2525 {
2626 }
2727
28- private void CreateGitFiles ( string repoDir , string originUrl )
28+ private void CreateGitFiles ( string repoDir , string originUrl , string commitSha = "1200000000000000000000000000000000000000" )
2929 {
3030 var gitDir = Path . Combine ( repoDir , ".git" ) ;
3131 var headsDir = Path . Combine ( gitDir , "refs" , "heads" ) ;
3232
3333 Directory . CreateDirectory ( gitDir ) ;
3434 File . WriteAllText ( Path . Combine ( gitDir , "HEAD" ) , "ref: refs/heads/master" ) ;
3535 Directory . CreateDirectory ( headsDir ) ;
36- File . WriteAllText ( Path . Combine ( headsDir , "master" ) , "1200000000000000000000000000000000000000" ) ;
36+
37+ if ( commitSha != null )
38+ {
39+ File . WriteAllText ( Path . Combine ( headsDir , "master" ) , commitSha ) ;
40+ }
3741
3842 if ( originUrl != null )
3943 {
@@ -81,6 +85,28 @@ public void WithNoGitMetadata()
8185 intermediateDir . Should ( ) . NotHaveFile ( "SourceLinkTestApp.sourcelink.json" ) ;
8286 }
8387
88+ /// <summary>
89+ /// When creating a new repository locally we want the build to work and not report warnings even before the remote is set.
90+ /// </summary>
91+ [ Fact ]
92+ public void WithNoRemoteNoCommit ( )
93+ {
94+ var testAsset = _testAssetsManager
95+ . CopyTestAsset ( "SourceLinkTestApp" )
96+ . WithSource ( ) ;
97+
98+ CreateGitFiles ( testAsset . Path , originUrl : null , commitSha : null ) ;
99+
100+ var buildCommand = new BuildCommand ( testAsset ) ;
101+ buildCommand . Execute ( ) . Should ( ) . HaveStdOutContaining ( $ "warning : Repository '{ testAsset . Path } ' has no remote.") ;
102+
103+ var intermediateDir = buildCommand . GetIntermediateDirectory ( ) ;
104+ intermediateDir . Should ( ) . NotHaveFile ( "SourceLinkTestApp.sourcelink.json" ) ;
105+ }
106+
107+ /// <summary>
108+ /// When creating a new repository locally we want the build to work and not report warnings even before the remote is set.
109+ /// </summary>
84110 [ Fact ]
85111 public void WithNoRemote ( )
86112 {
0 commit comments