【发布时间】:2020-04-10 09:19:54
【问题描述】:
我们正在使用 GIT 进行部署,而且一切运行良好。目前我正在编写允许客户端切换到另一个部署存储库的功能 - 毕竟我们可能会在某个时候决定从不同的位置开始部署,对吧?
我们在 Azure 中创建存储库,并在创建存储库后使用按钮生成 GIT 凭据:
所以我向用户展示了一个表单,他们可以在其中输入新的 URL、用户名和密码,然后我去检查....(vb.net 代码)
Dim oCH As LibGit2Sharp.Handlers.CredentialsHandler = Nothing
Dim oItems As IEnumerable(Of LibGit2Sharp.Reference) = Nothing
Dim oCred As LibGit2Sharp.UsernamePasswordCredentials = Nothing
Try
oCred = New LibGit2Sharp.UsernamePasswordCredentials
oCred.Username = tbBuildsCredential.Password
oCred.Password = tbBuildsPassword.Password
oCH = New LibGit2Sharp.Handlers.CredentialsHandler(Function(_url, _user, _cred) oCred)
oItems = LibGit2Sharp.Repository.ListRemoteReferences(url:=tbBuildsRepository.Text,
credentialsProvider:=oCH)
If oItems Is Nothing Then
Return False
End If
Catch ex As Exception
(我将省略最后的错误处理和清理代码,因为它不相关)
好的 - 所以我正在对此进行测试,并在 azure devops 中输入一个有效的存储库 URL:
https://<ourcompanynamehere>@dev.azure.com/<ourcompanynamehere>/<projectnamehere>/_git/<repohere>
我使用了一个有效的用户名和密码,一切都很好,花花公子,它返回一个 oItems 对象,它的 .Count > 0 ...快乐的日子。所以我尝试使用一些无效值来查看会发生什么... 无效的 URL 返回 此遥控器从未连接过 - 快乐的日子!所以我尝试使用正确的 URL 但无效的用户名....哇等等....它仍然返回一个有效的 oItems 对象???当我破坏密码时,它再次返回 此遥控器从未连接过,但似乎用户名被完全忽略了。
这是 dev.azure.com 的 GIT 方式中的错误吗?这是我需要担心的事情吗?如果无论如何都要忽略“用户名”,为什么还要有一个“用户名”?
【问题讨论】:
标签: git azure-devops libgit2sharp