#768  clone repo via rest API
Released
crash opened 2 years ago

Hi, I'm new to OneDev but totally in love with it, great work, thank you!

Anyway, I'm making a script to auto-clone an existing external repo (for example on github) to my onedev instance via REST API.

After studying the documentation I did imagine this solution:

#Step 1 - create the project

curl -u user:token -d@create.json -H "Content-Type: application/json" https://my.one.dev/api/projects

#Step 2 - add the .onedev-buildspec.yml file to the newly created project with a PullRepository step

curl -u user:token -d@clone.json -H "Content-Type: application/json" https://my.one.dev/api/repositories/25/files/master/.onedev-buildspec.yml

and here comes the troubles: the server complains because still no master (or any other) branch exist in an empty project, so I thought to create it through the /api/repositories/{projectId}/branches endpoint, but looking at the documentation a commit revision is mandatory

{
    "revision" : "46c001b04cba0ca41588841f1ca32f50b582ee9b",
    "branchName" : "string"
}

Unfortunately since the repository is still empty I don't have any revision to specify, so basically i'm stuck :D

What am I missing?

Robin Shen commented 2 years ago

Thanks for using OneDev. It is verified to be a bug. The editFile endpoint should allow files being created against empty repository. Will be addressed in next patch release.

OneDev changed state to 'Closed' 2 years ago
Previous Value Current Value
Open
Closed
OneDev commented 2 years ago

State changed as code fixing the issue is committed

OneDev changed state to 'Released' 2 years ago
Previous Value Current Value
Closed
Released
OneDev commented 2 years ago

State changed as build #2755 is successful

crash commented 2 years ago

Wow, a fix released in less than 24hours, you’re blazing fast - I’m impressed.

I can confirm everything works as expected now.

Thank you.

issue 1 of 1
Type
Bug
Priority
Normal
Assignee
Affected Versions
Not Found
Issue Votes (0)
Watchers (4)
Reference
onedev/server#768
Please wait...
Page is in error, reload to recover