libgit2 / libgit2/pygit2

Pygit2 cannot parse URLs with OAuth tokens.

未關閉
#554 8 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
1.7k
分支
408
平均合併
2 天 57 分鐘
30 天內合併 PR
7

描述

I'm trying to use pygit2 to clone a GitHub repo using OAuth tokens.
This actually works well from the command line, as explained on GitHub's blog here.

So, I do:

from pygit2 import clone_repository

oauth_token = 'somesuperlongtokengivenbygithub'
repo = clone_repository(
                'https://'+oauth_token+'@github.com/openwrt/luci', 
                '/tmp/repos', 
                bare=True
)

and I get back:

00:04:42 _pygit2.GitError: Unsupported URL protocol
Traceback (most recent call last):
  File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/rq/worker.py", line 558, in perform_job
    rv = job.perform()
  File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/rq/job.py", line 495, in perform
    self._result = self.func(*self.args, **self.kwargs)
  File "/home/ubuntu/repo/etincelle/routes.py", line 41, in clone_all_repos
    clone(repo, _app, token)
  File "/home/ubuntu/repo/etincelle/routes.py", line 25, in clone
    clone_repository(oauth_url, git_id_repo, bare=True)
  File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/pygit2/__init__.py", line 293, in clone_repository
    check_error(err)
  File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/pygit2/errors.py", line 64, in check_error
    raise GitError(message)
_pygit2.GitError: Unsupported URL protocol
Traceback (most recent call last):
  File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/rq/worker.py", line 558, in perform_job
    rv = job.perform()
  File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/rq/job.py", line 495, in perform
    self._result = self.func(*self.args, **self.kwargs)
  File "/home/ubuntu/repo/etincelle/routes.py", line 41, in clone_all_repos
    clone(repo, _app, token)
  File "/home/ubuntu/repo/etincelle/routes.py", line 25, in clone
    clone_repository(oauth_url, git_id_repo, bare=True)
  File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/pygit2/__init__.py", line 293, in clone_repository
    check_error(err)
  File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/pygit2/errors.py", line 64, in check_error
    raise GitError(message)
_pygit2.GitError: Unsupported URL protocol

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 pygit2/init.py 中所示的 clone_repository 呼叫開始,檢查 URL 如何到達 errors.py 中的錯誤檢查。重現 OAuth 權杖 URL 的情況,將其與 issue 中描述的命令列行為進行比較,並判斷現有的 URL 或驗證處理中哪一項適用。完成標準是 clone_repository 接受文件所述的 GitHub 權杖 URL,而不引發 Unsupported URL protocol。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
git, python
領域
authentication, backend
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。