This repository was archived by the owner on Feb 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,29 @@ public void CanListRemoteReferenceObjects()
107
107
}
108
108
}
109
109
110
+ [ SkippableFact ]
111
+ public void CanListRemoteReferencesWithCredentials ( )
112
+ {
113
+ InconclusiveIf ( ( ) => string . IsNullOrEmpty ( Constants . PrivateRepoUrl ) ,
114
+ "Populate Constants.PrivateRepo* to run this test" ) ;
115
+
116
+ string remoteName = "origin" ;
117
+
118
+ string repoPath = InitNewRepository ( ) ;
119
+
120
+ using ( var repo = new Repository ( repoPath ) )
121
+ {
122
+ Remote remote = repo . Network . Remotes . Add ( remoteName , Constants . PrivateRepoUrl ) ;
123
+
124
+ var references = repo . Network . ListReferences ( remote , Constants . PrivateRepoCredentials ) ;
125
+
126
+ foreach ( var directReference in references )
127
+ {
128
+ Assert . NotNull ( directReference ) ;
129
+ }
130
+ }
131
+ }
132
+
110
133
[ Theory ]
111
134
[ InlineData ( FastForwardStrategy . Default ) ]
112
135
[ InlineData ( FastForwardStrategy . NoFastFoward ) ]
Original file line number Diff line number Diff line change @@ -46,13 +46,21 @@ public virtual RemoteCollection Remotes
46
46
/// </para>
47
47
/// </summary>
48
48
/// <param name="remote">The <see cref="Remote"/> to list from.</param>
49
+ /// <param name="credentials">The optional <see cref="Credentials"/> used to connect to remote repository.</param>
49
50
/// <returns>The references in the <see cref="Remote"/> repository.</returns>
50
- public virtual IEnumerable < DirectReference > ListReferences ( Remote remote )
51
+ public virtual IEnumerable < DirectReference > ListReferences ( Remote remote , Credentials credentials = null )
51
52
{
52
53
Ensure . ArgumentNotNull ( remote , "remote" ) ;
53
54
54
55
using ( RemoteSafeHandle remoteHandle = Proxy . git_remote_load ( repository . Handle , remote . Name , true ) )
55
56
{
57
+ if ( credentials != null )
58
+ {
59
+ var callbacks = new RemoteCallbacks ( null , null , null , credentials ) ;
60
+ GitRemoteCallbacks gitCallbacks = callbacks . GenerateCallbacks ( ) ;
61
+ Proxy . git_remote_set_callbacks ( remoteHandle , ref gitCallbacks ) ;
62
+ }
63
+
56
64
Proxy . git_remote_connect ( remoteHandle , GitDirection . Fetch ) ;
57
65
return Proxy . git_remote_ls ( repository , remoteHandle ) ;
58
66
}
You can’t perform that action at this time.
0 commit comments