-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚧 Add Gogs support #82
Conversation
if verify.lower().strip() in ('0','no','false',''): | ||
verify = False | ||
elif verify.lower().strip() in ('1','yes','true'): | ||
verify = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is being implemented in another pull request, which is ready and will be released along the next release (which is due relatively soon, it's mostly depending on Gitlab to merge a patch I made).
So I'm merging that PR into devel (I actually thought I already did), so you can rebase your branch and use self.insecure
instead of verify.
elif verify.lower().strip() in ('1','yes','true'): | ||
verify = True | ||
self.default_private = self.config.get('default-private', 'true').lower() not in ('0','no','false') | ||
self.ssh_url = self.config.get('ssh-url', None) or self.fqdn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it likely that ssh_url
would be different than based on fqdn
? The assumption I'm making with self-hosted gitlab is that the fqdn for both ssh and http is the same, so for homogeinity I'd rather do the same here (and if it's wrong, then maybe make a fix for both gogs and gitlab), but I'm open to counter arguments on it.
And BTW the way you're using it, it's actually ssh_fqdn
as an URL is supposed to look like ssh:https://
and might contain a path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ssh-url can contains either fqdn with non-standard port 127.0.0.1:3022
, or "fqdn" that refers some alias in ~/.ssh/config
with Port
and other parameters (i.e. ProxyCommand
) pre-customized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm… ok, though it's not the right place to configure that, it should be done the same way self.insecure
is implemented, so all services can access that (as both gitlab and github can run on private instances).
if proxy: | ||
proxies[scheme] = proxy | ||
try: | ||
self.session = requests.Session() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The session shall be created in __init__
, ideally when instanciating the external library that abstract the API. The reason for that is that the tests rely on the session instance to be monkey patched in order to be recorded and replayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connect()
is called from git_repo.services.service.RepositoryService.__init__
, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not necessarily, only if a repository argument is given to the __init__()
. Basically, the tests framework is designed on the fact that instanciation of the requests.Session()
(and any abstraction in between) is setup in __init__()
whereas the connection is setup in connect()
, making it then possible to hijack the Session
instance in between.
if not verify: | ||
try: | ||
import urllib3 | ||
urllib3.disable_warnings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you disabling urllib3 warnings? If it needs to yell, let it yell! ☺
if not self._privatekey: | ||
raise ConnectionError('Could not connect to GoGS. ' | ||
'Please configure .gitconfig ' | ||
'with your github private key.') from err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/github/GoGS/
☺
verify = False | ||
elif verify.lower().strip() in ('1','yes','true'): | ||
verify = True | ||
self.default_private = self.config.get('default-private', 'true').lower() not in ('0','no','false') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not for a config option for that, which would then be not homogeneous with the other services. Though you're making a good point here, we're missing private
status of a repository creation in the API, so I believe we should add a --private
argument to both create
and fork
.
About the configurations (and setting up defaults), there's issue #46 discussing this, which aims at doing things in a smart way, until then adding CLI parameters shouldn't be too much of a pain. So, I believe a good time to think about that would be for 2.0!
for scheme in 'http https'.split(): | ||
proxy = config.get_value(scheme, 'proxy', '') | ||
if proxy: | ||
proxies[scheme] = proxy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proxies support is a great idea I totally did not think of…
but again, it should be implemented outside of the service implementation, so that it's accessible to all services (the same way self.insecure
is implemented).
so either you remove it, and make an issue/PR to add this globally, or you leave it, and we'll replace that when we'll implement proxy support across services. Not sure what's the smartest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened #105 about that.
ok, so first of all I'm stumped that there's no API for forking a project! It's like one of the most basic feature to be expected from such a service 😖 And I hope that requests will land soon… BTW requests alone without a git ref that can be fetched is only half the feature… That being said, it's a great job you've done 👍 I prefer to work on with a library that can gather more efforts from different projects implementing it to make it right, and eventually to maintain it when the remote API changes. And, then the At the very least, if you want to roll your own API implementation (which is pretty clean overall), I'd then ask you to move it all within its own class:
and then use that within |
Ok. Let's close this one and I'll implement it second time from scratch. |
you can actually keep that PR and squash the merges ( |
ab2f09a
to
a017ffd
Compare
a017ffd
to
de317f3
Compare
(actually merged) |
Current status:
config
list
andlist -l
open
add
create
delete
clone
verify
- yes/no or path to ca-bundledefault-private
- set to yes if new repositories should be privatessh-url
- i.e. 127.0.0.1:3022get_auth_token
can't return alternative fqdn and other custom options back to config command.resolves #18