G-Node / tonic

Framework for building services that interact with GIN
BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

error in creating submodules ? #35

Closed jcolomb closed 3 years ago

jcolomb commented 3 years ago

trying to use tonic with https://gindata.biologie.hu-berlin.de/G-Node/template_parent

json:

{
  "gin": {
    "web": "https://gindata.biologie.hu-berlin.de:443",
    "git": "git@gindata.biologie.hu-berlin.de:10022",
    "username": "testbot",
    "password": "testbot"
  },

  "templaterepo": "G-node/template_parent",
  "cookiename": "utonic-labproject",
  "dbpath": "./labproject.db"
}

log:

    Cloning template repository G-node/template_parent
    Creating testtonic/testproject_n4
    Repository created: testtonic/testproject_n4
    Preparing to push template to new project (adding remote): ssh://git@gindata.biologie.hu-berlin.de:10022/testtonic/testproject_n4
    Added new remote: newproject [ssh://git@gindata.biologie.hu-berlin.de:10022/testtonic/testproject_n4]
    Cloning submodules
    Creating testtonic/testproject_n4.05_figures/990_shared_figures
    Failed to create repository: json: cannot unmarshal array into Go value of type map[string]interface {}
jcolomb commented 3 years ago

NB: testbot is not a site admin, just a normal user, is that the problem?

just seen the terminal was also giving some log, it gets a different error first: load pubkey "/root/.config/g-node/gin/gin.key": invalid format

achilleas-k commented 3 years ago
    Cloning template repository G-node/template_parent
    Creating testtonic/testproject_n4
    Repository created: testtonic/testproject_n4
    Preparing to push template to new project (adding remote): ssh://git@gindata.biologie.hu-berlin.de:10022/testtonic/testproject_n4
    Added new remote: newproject [ssh://git@gindata.biologie.hu-berlin.de:10022/testtonic/testproject_n4]
    Cloning submodules
    Creating testtonic/testproject_n4.05_figures/990_shared_figures
    Failed to create repository: json: cannot unmarshal array into Go value of type map[string]interface {}

This is very strange because the line it failed on:

Creating testtonic/testproject_n4.05_figures/990_shared_figures
Failed to create repository: json: cannot unmarshal array into Go value of type map[string]interface {}

Is the same code as the first repo creation that worked

Creating testtonic/testproject_n4
Repository created: testtonic/testproject_n4
achilleas-k commented 3 years ago

Oh wait, I see the issue.

It tried to create a repository called testtonic/testproject_n4.05_figures/990_shared_figures. This isn't valid.

This is a bug. It assumes that submodules are in the root of the repository, so it uses the path of the submodule to name the new repository for it, which if it's nested, will have a / and wont be a valid repository path on the server.

I'll fix this.

achilleas-k commented 3 years ago

Can you post the contents of the .gitmodules file for this repository?

achilleas-k commented 3 years ago

Since this is just for the labproject service, how would you like this to work?

The repository name for the submodule is created by appending the name of the original (template) submodule to the name of the new project. In this case where the name of the submodule contains a /, I can think of two ways to do it:

  1. testproject_n4.05_figures_990_shared_figures: Replace the / with a _.
  2. testproject_n4.990_shared_figures: Use only the last path component of the submodule name/path.

The first would be more robust. The second one could cause conflicts if there are two submodules with the same basename but in different subdirectories. I realise that with the template naming scheme this shouldn't happen, but technically it could.

jcolomb commented 3 years ago

Let's go with the first one then.

.gitmodule of the template: https://gindata.biologie.hu-berlin.de/G-Node/template_parent/src/master/.gitmodules no one is created for testproject_n4