stash icon indicating copy to clipboard operation
stash copied to clipboard

update git.py for python3

Open DedSecer opened this issue 4 years ago • 5 comments

Command git for python3. (do not support python2)

(Still needs tests) Directly using dulwich(dulwich is more stronger now) without gittle now. (gittle it not update anymore now)

TODO

  • [ ] git checkout . and git add .
  • [ ] git config
  • [ ] git diff
  • [ ] git merge
  • [ ] set upstream
  • [ ] support ssh key
  • [ ] remote branch support

Known issues

  • Password input will be echoed while authorizing
  • github not support authorize by github password now.(use a personal access token or add a ssh key instead)

DedSecer avatar Aug 27 '21 12:08 DedSecer

@DedSecer Any progress here? I wouldn't want to merge a git implementation without ssh key support. Not having any Python 2 support is also a bit of a problem, but maybe it's time to thing about a Python-3-only-StaSh soon...

fschaeck avatar May 31 '22 08:05 fschaeck

@fschaeck Sorry,I am busying.Since somebody noticed this, I will trying to process,this could be very slow.

DedSecer avatar Jun 06 '22 11:06 DedSecer

Please rebase.

cclauss avatar May 04 '23 12:05 cclauss

This PR still can not work in Pythonista 3.4, So, I made some modifications to it and it finally worked properly.

Firstly, Pythonista doesn't support Subprocesses, so it cannot support shell hooks for git. So I commented out the code in the following files of Dulwich to avoid executing hooks: stash/lib/dulwich/repo.py, line 1104

        #self.hooks["pre-commit"] = PreCommitShellHook(self.controldir())
        #self.hooks["commit-msg"] = CommitMsgShellHook(self.controldir())
        #self.hooks["post-commit"] = PostCommitShellHook(self.controldir())
        #self.hooks["post-receive"] = PostReceiveShellHook(self.controldir())

Then, there is also a small issue in the git.py file of this PR. At function git_ add, when adding files, it check whether they are in the repo index. Doing so will result in the inability to add new files. So I shortcut this checking: stash/bin/git.py, line 348

if True or file.encode() in repo.open_index():

Finally, it works correctly.

tringcooler avatar May 31 '23 12:05 tringcooler