Programmatically `git checkout .` with dulwich

前端 未结 3 1160
[愿得一人]
[愿得一人] 2020-12-30 15:50

Having this code

from dulwich.objects import Blob, Tree, Commit, parse_timezone
from dulwich.repo import Repo
from time import time

repo = Repo.init(\"myrep         


        
3条回答
  •  半阙折子戏
    2020-12-30 16:16

    from dulwich.repo import Repo
    
    repo = Repo.init('myrepo', mkdir=True)
    f = open('myrepo/spam', 'w+')
    f.write('my file content\n')
    f.close()
    repo.stage(['spam'])
    repo.do_commit('initial commit', 'Flav ')
    

    Found by looking at dulwich/tests/test_repository.py:371. dulwich is powerful but the docs are a bit lacking, unfortunately.

    May also want to consider using GitFile instead.

提交回复
热议问题