Closed emirot closed 2 years ago
Updating this thread, it's difficult to have similar builds so I would like to use a docker image
Dockerfile
FROM ubuntu
RUN apt update -y
RUN apt install -y build-essential zlib1g-dev libncurses5-dev
RUN apt install -y libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
RUN apt install -y python3 python3-pip git
RUN apt install -y gcc libc-dev g++
# https://github.com/libgit2/pygit2/issues/999
RUN pip3 install -U pip
RUN pip3 install --upgrade pip
RUN pip install pygit2
RUN pip install battenberg
COPY .git/ .
COPY . .
I'm running docker build in a project that is using cookie cutter and battenberg. Then I create a ssh-keygen key pair and add it in my gitlab ssh keys in console.
I get
root@000439d4ad86:/# battenberg upgrade
Traceback (most recent call last):
File "/usr/local/bin/battenberg", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/battenberg/cli.py", line 112, in upgrade
battenberg.upgrade(**kwargs)
File "/usr/local/lib/python3.8/dist-packages/battenberg/core.py", line 234, in upgrade
self._fetch_remote_template()
File "/usr/local/lib/python3.8/dist-packages/battenberg/core.py", line 49, in _fetch_remote_template
self.repo.remotes['origin'].fetch([TEMPLATE_BRANCH],
File "/usr/local/lib/python3.8/dist-packages/pygit2/remote.py", line 147, in fetch
payload.check_error(err)
File "/usr/local/lib/python3.8/dist-packages/pygit2/callbacks.py", line 91, in check_error
raise self._stored_exception
File "/usr/local/lib/python3.8/dist-packages/pygit2/callbacks.py", line 331, in wrapper
return f(*args)
File "/usr/local/lib/python3.8/dist-packages/pygit2/callbacks.py", line 376, in _credentials_cb
ccred = get_credentials(credentials, url, username, allowed)
File "/usr/local/lib/python3.8/dist-packages/pygit2/callbacks.py", line 471, in get_credentials
raise TypeError("invalid credential type")
TypeError: invalid credential type
root@f895e63ffcd6:/# python3 -c "import pygit2; print(bool(pygit2.features & pygit2.GIT_FEATURE_SSH))" True This returns True What really drives me crazy is this:
import pygit2
import getpass
def main():
keypair = pygit2.KeypairFromMemory(
"git",
str(Path('~/.ssh/id_rsa.pub').expanduser().read_text()),
str(Path('~/.ssh/id_rsa').expanduser().read_text()),
"")
pygit2.clone_repository(
'ssh://git@org.net/fastapi.git', 'empty',
callbacks=pygit2.RemoteCallbacks(credentials=keypair))
if __name__ == '__main__':
main()
by adding my ssh key it works and I can pull a repo, but battenberg still give me an issue.
Looks like it happens when the template branch is missing.
Your branch is up to date with 'origin/main'.
root@73cdaf79173c:~# battenberg upgrade --checkout demo-to-nolan --no-input
root@73cdaf79173c:~# git branch -D template
Deleted branch template (was f0b9d97).
root@73cdaf79173c:~# battenberg upgrade --checkout demo-to-nolan --no-input
Traceback (most recent call last):
File "/usr/local/bin/battenberg", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/battenberg/cli.py", line 112, in upgrade
battenberg.upgrade(**kwargs)
File "/usr/local/lib/python3.8/dist-packages/battenberg/core.py", line 234, in upgrade
self._fetch_remote_template()
File "/usr/local/lib/python3.8/dist-packages/battenberg/core.py", line 49, in _fetch_remote_template
self.repo.remotes['origin'].fetch([TEMPLATE_BRANCH],
File "/usr/local/lib/python3.8/dist-packages/pygit2/remote.py", line 147, in fetch
payload.check_error(err)
File "/usr/local/lib/python3.8/dist-packages/pygit2/callbacks.py", line 91, in check_error
raise self._stored_exception
File "/usr/local/lib/python3.8/dist-packages/pygit2/callbacks.py", line 331, in wrapper
return f(*args)
File "/usr/local/lib/python3.8/dist-packages/pygit2/callbacks.py", line 376, in _credentials_cb
ccred = get_credentials(credentials, url, username, allowed)
File "/usr/local/lib/python3.8/dist-packages/pygit2/callbacks.py", line 471, in get_credentials
raise TypeError("invalid credential type")
TypeError: invalid credential type
I'm trying to use that tool by running:
I have also have a
.cookiecutter.json
that I can share.Python version: Python 3.7.9 Pip freeze:
Stacktrace:
So I thought something was wrong with my git configuration so I tried:
And it worked fine. Any ideas what I'm doing wrong?