dspinellis / git-issue

Git-based decentralized issue management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

import/export issue from self hosted gitlab instance ?

dtrckd opened this issue · comments

Hi,

Is it possible to use the import/export functionality to work with self hosted instance of gitlab with given url ?
I couldn't manage to do it.

Great code !

Thank you! I see that the https://gitlab.com/api API endpoint URL is hard-coded in a number of places. We'd need to add a -u option to set the API endpoint URL for the import and export commands. I'd welcome a pull request to add this functionality.

Thanks for your response @dspinellis.

I checked the code and I could change the endpoint by adding manually a variable in the config file present in the issues folder and the corresponding parser in import-export.sh.
It seems to works well and prevent for entering the endpoint/url option again and again.
What do you think about this approach ?

PS: I think I found a bug. My server returns a HEADER start with HTTP/2 200 , but in the line 96 (*) of import-export.sh it throw an "connection failure" because it looks for string "Status" but this string is not present in the header...

(*) if ! grep -q '^\(Status: 200\|HTTP/[[:digit:]].[[:digit:]] 200 OK\)' "$prefix-header" ; then

Thank you for the feedback!

Let's keep the header problem in a separate issue. (I believe the header status is mandatory, so the problem may be something else.)

Storing the endpoint in the configuration file is a good idea. However, I'd like to have a way to set it from the command line, as is done with git-config. Is there a precedent for Git setting options only by directly editing the file? (I am doing it, but I understand there are better alternatives.)

Yes, I think having something like git issue config provider_domain http://myowngitlab.xyz would be great.

In git I believe we can directly change the config either with the command line or by editing the config file.

It's probably not the better way to do it, but still, this if it can help, here is the main modification I did in the import-export.sh file to check the config file :

GITLAB_PROVIDER="https://gitlab.com"                                                                                                                                                                               
while read -r name value                                                                                                                                                                                           
do                                                                                                                                                                                                                 
    if [ "$name" = "provider_domain" ]; then                                                                                                                                                                       
        GITLAB_PROVIDER=$(echo $value | sed  "s/^ *= *//")                                                                                                                                                         
    fi                                                                                                                                                                                                             
    if [ "$name" = "gitlab_token" ]; then                                                                                                                                                                          
        GL_CURL_AUTH="PRIVATE-TOKEN: $(echo $value | sed  "s/^ *= *//")"                                                                                                                                           
    fi                                                                                                                                                                                                             
    if [ "$name" = "github_token" ]; then                                                                                                                                                                          
        GH_CURL_AUTH="Authorization: token $(echo $value | sed  "s/^ *= *//")"                                                                                                                                     
    fi                                                                                                                                                                                                             
done < .issues/config 

Nice! If you use case rather than if and expr rather than echo | sed it will be perfect. Are the variables visible outside the while loop?

Yes, at the beginning of the script.