Add gogs support
guyzmo opened this issue · 12 comments
If there are no objections I'm going to implement this one.
I got no objections, don't hesitate to ask for my help on anything. I wanted to work on it recently, as I started pushing to a friend's gogs, but I already got my hands full with both the gitlab and bitbucket integrations.
I'm also available on freenode on the channel #git-repo so please come and never hesitate to discuss the project.
for the tests, @pyhedgehog, please come back on IRC so we can discuss quickly what's going wrong.
Just to log here results of our discussion:
- New version of PR should use third-party library (possibly gogs-client).
- There are several most wanted features in gogs and gogs-client:
- Features for proxy, private and ssl_verify should be implemented in service-independent manner.
- Test should be first-class thing. 👍
for the feature set, go by babysteps:
- implement first the already working features, like you first did (clone, create, delete, open, list) and consider that the user can copy/paste the token in the configuration file
- implement the token API as a second step, the best way would be for you to send a PR to gogs-client for them to integrate it, so then git-repo can merge it in!
- add the extra stuff we might want to have… You could make a PR to gogs to integrate the fork API, we can 🤞 that PR api lands soon… or you could implement some web scrapping (either in gogs-client or in a third part library extending gogs-client) to support those features.
About the configuration features:
ssl_verify
is already implemented and I'm merging it in develop, just look forself.insecure
onRepositoryService
,proxy
support is a good thing to have (using the.gitconfig
proxy setting), and I believe it's a good case for a new issue and PR, adding it for the four services.private
should be a command line argumentgit gogs foo/bar create --private
. And there's already an issue to discuss default configuration implementation, but it's not a priority currently.
About the tests, I did my best to make them easy to write and run, of course I'm around if you need any help.
FYI, I actually just checked with a gogs install, I believe it's possible to make a fork, given that the token auth works for this use case:
if you make a POST
request with form data containing:
uid
→ id of the new owner, i.e. current userrepo_name
→ new name of the repositorydescription
→ description of what is that repository
to the URL: /repo/fork/{id of the repository to fork}
that should work!
N.B.: I believe there's a visibility
parameter, but for my tests, I couldn't check as I was forking a private repository.
implementation for tokens in progress over unfoldingWord-dev/python-gitea-client#2 👍
BTW, in the module http_utils you'll have to have init create a requests.Session
object and replace all requests
calls with it. The patch should be fairly straightforward.
Also, we need to make sure that RelativeHttpRequestor
(or the requests session within) is a singleton instance across the API lib — which I believe it is.
That's very important to have that in order to be able to write tests in git-repo.
if you make a POST request ... to the URL: /repo/fork/{id of the repository to fork} that should work!
How you've avoided Bad Request: no CSRF token present
result?
There are several most wanted features in gogs
@pyhedgehog Please make an issue for each (unless there already is one) so that the devs (myself included) are aware of the need 🙂
@bkcsoft well the two most important missing APIs (AFAICT):
- fork a repository: gogs/gogs#3979
- create a pull request: gogs/gogs#2253
- one feature is very important to have is the ability to expose pull requests as git refs that can be fetched (on github it's like
git fetch github pull/42/head
).
- one feature is very important to have is the ability to expose pull requests as git refs that can be fetched (on github it's like
and generally for feature completeness:
- The snippet feature would be nice as well: gogs/gogs#936
I'll leave @pyhedgehog make an issue about repository listing, as I'm not sure to the details of the repository listing limitations. Some other API might be nice to have (like the ability to list and push SSH public keys, or have oauth2 authentication).