Skip to content

Some points about the experimental git integration #84

@Narrat

Description

@Narrat

I recently discovered this tool and thought it could be an idea to get rid of my various text files :D Well, I'll see how it will work out.
While tinkering with the tool I tried the experimental sync feature via git. And noticed some points (didn't look at the source yet, so maybe my observations are wrong)

  1. branch name main seems to be hardcoded? Causes issues with pushing, if git still creates master or whatever as the main branch as default
  2. every kb sync push creates a commit

regarding 1.:
Remote (and local, but that I discovered later) repo had a different branchname, which caused the following error:

Create a remote empty repository on github/gitlab or other git provider...
Insert the URL of the created empty remote repo (e.g., https://github/user/mykb): Clio:Backup/Repository/kb.git
Initialization with remote may take time...
Please provide remote credentials and wait...
Traceback (most recent call last):
  File "/usr/bin/kb", line 33, in <module>
    sys.exit(load_entry_point('kb-manager==0.1.6', 'console_scripts', 'kb')())
  File "/usr/lib/python3.9/site-packages/kb/main.py", line 66, in main
    dispatch(cmd, cmd_params, config=DEFAULT_CONFIG)
  File "/usr/lib/python3.9/site-packages/kb/main.py", line 56, in dispatch
    return COMMANDS[function](*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/kb/commands/sync.py", line 46, in sync
    git_init(config["PATH_KB"])
  File "/usr/lib/python3.9/site-packages/kb/commands/sync.py", line 126, in git_init
    remote.push(refspec='{}:{}'.format("main", "main"))
  File "/usr/lib/python3.9/site-packages/git/remote.py", line 848, in push
    return self._get_push_info(proc, progress)
  File "/usr/lib/python3.9/site-packages/git/remote.py", line 735, in _get_push_info
    proc.wait(stderr=stderr_text)
  File "/usr/lib/python3.9/site-packages/git/cmd.py", line 408, in wait
    raise GitCommandError(self.args, status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git push --porcelain origin main:main
  stderr: 'error: src refspec main does not match any
error: failed to push some refs to 'Clio:Backup/Repository/kb.git''

After changing it on the remote if failed again. Because the local repo also had a different branchname from what the program assumed/expected:

~ $ kb sync push
zsh: correct 'sync' to 'Sync' [nyae]? n
Some error occured while pushing the code
Check your internet connection or the existence of the remote repository 

regarding 2.: It shouldn't create a commit which then gets pushed, if there is no change in the local repo.
Additional thought about this: When should the commit be created? Either after every add, edit or whatever operation changes the local state in the repo. Or stay with the current implementation. Personally I like the first. Which I luckily can do even if you don't want to change the behaviour, which would be perfectly fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions