ADD Gemfile.lock
bundle install
进入项目根目录执行一下命令:
cp config/configuration.yml.example config/configuration.yml cp config/database.yml.example config/database.yml touch config/redis.yml touch config/elasticsearch.yml
rails db:create
bundle exec rake sync_table_structure:import_csv
rails db:migrate RAILS_ENV=development
rails s
在浏览器中输入如下地址访问:
http://localhost:3000/projects
开发API服务地址:
https://testgitea.trustie.net/
响应状态说明:
POST accounts/remote_register
示例
curl -X POST \ -d "email=2456233122@qq.com" \ -d "password=djs_D_00001" \ -d "username=16895620" \ -d "platform=forge" \ http://localhost:3000/api/accounts/remote_register | jq
请求参数说明:
返回参数说明:
返回值
{ "status": 0, "message": "success", "user": { "id": 36400, "token": "8c87a80d9cfacc92fcb2451845104f35119eda96" } }
GET api/users/me
curl -X GET http://localhost:3000/api/users/me | jq
{ "username": "18816895620", "login": "18816895620", "user_id": 36401, "image_url": "avatars/User/b", "admin": false }
GET api/users/list
curl -X GET \ -d "limit=10" \ -d "search=18816895620" http://localhost:3000/api/users/list | jq
{ "total_count": 1, "users": [ { "username": "18816895620", "login": "18816895620", "user_id": 36401, "image_url": "avatars/User/b" } ] }
GET api/project_categories
curl -X GET \ -d "name=大数据" \ http://localhost:3000/api/project_categories/ | jq
{ "project_categories": [ { "id": 1, "name": "大数据" } ] }
GET api/project_languages
curl -X GET \ -d "name=Ruby" \ http://localhost:3000/api/project_languages/ | jq
{ "project_languages": [ { "id": 1, "name": "Ruby" } ] }
GET api/ignores
curl -X GET \ -d "name=Ada" \ http://localhost:3000/api/ignores/ | jq
{ "ignores": [ { "id": 1, "name": "Ada" } ] }
GET api/licenses
curl -X GET \ -d "name=AFL" \ http://localhost:3000/api/licenses/ | jq
{ "licenses": [ { "id": 57, "name": "AFL-1.2" }, { "id": 76, "name": "AFL-3.0" }, { "id": 214, "name": "AFL-1.1" }, { "id": 326, "name": "AFL-2.1" }, { "id": 350, "name": "AFL-2.0" } ] }
POST api/projects
curl -X POST \ -d "user_id=36401" \ -d "name=hnfl_demo" \ -d "description=my first project" \ -d "repository_name=hnfl_demo" \ -d "project_category_id=1" \ -d "project_language_id=2" \ -d "ignore_id=2" \ -d "license_id=1" \ http://localhost:3000/api/projects/ | jq
{ "id": 3240, "name": "好项目" }
POST api/projects/migrate
curl -X POST \ -d "user_id=36401" \ -d "clone_addr=https://gitea.com/mx8090alex/golden.git" \ -d "name=golden" \ -d "description=golden" \ -d "repository_name=golden" \ -d "project_category_id=1" \ -d "project_language_id=2" \ http://localhost:3000/api/projects/migrate | jq
{ "id": 3263, "name": "ni项目" }
GET api/projects/:id
curl -X GET http://localhost:3000/api/projects/3263 | jq
{ "name": "ni项目", "identifier": "mirror_demo", "is_public": true, "description": "my first project mirror_demo", "repo_id": 75073, "repo_identifier": "mirror_demo" }
GET /api/:login/:repo_identifier/edit.json
curl -X GET http://localhost:3000/api/18816895620/mirror_demo/edit.json | jq
{ "identifier": "mirror_demo", "project_id": 3263, "project_name": "ni项目", "project_identifier": "mirror_demo", "project_description": "my first project mirror_demo", "project_category_id": 1, "project_language_id": 2, "private": false }
PATCH api/projects/:id
curl -X PATCH \ -d "name=hnfl_demo" \ -d "description=my first project" \ -d "project_category_id=1" \ -d "project_language_id=2" \ -d "private=true" \ http://localhost:3000/api/projects/3263.json | jq
{ "id": 3263, "identifier": "mirror_demo", "name": "hnfl_demo", "description": "my first project", "project_category_id": 1, "project_language_id": 2, "is_public": true }
DELETE api/projects/:id
curl -X DELETE http://localhost:3000/api/projects/3263.json | jq
注:只有超级管理员和项目拥有者才能删除仓库
{ "status": 0, "message": "success" }
POST api/projects/:id/members
curl -X POST \ -d "user_id=36406" \ http://localhost:3000/api/projects/3297/members | jq
DELETE api/projects/:id/members/remove
curl -X DELETE \ -d "user_id=36400" \ http://localhost:3000/api/projects/3263/members/remove | jq
PUT api/projects/:id/members/change_role
curl -X PUT \ -d "user_id=36400" \ -d "role=Developer" \ http://localhost:3000/api/projects/3263/members/change_role | jq
GET api/projects/:id/members
curl -X GET \ -d "page=1" \ -d "limit=5" \ http://localhost:3000/api/projects/3263/members | jq
{ "total_count": 2, "members": [ { "id": 36401, "name": "18816895620", "login": "18816895620", "image_url": "avatars/User/b", "is_owner": true, "role": "Manager" }, { "id": 36399, "name": "18816365620", "login": "18816365620", "image_url": "avatars/User/b", "is_owner": false, "role": "Developer" } ] }
POST /api/projects/:project_id/forks
curl -X POST http://localhost:3000/api/projects/3297/forks | jq
{ "id": 3290, "identifier": "newadm" }
POST api/:login/:repo_identifier/entries
curl -X GET \ -d "ref=develop" \ http://localhost:3000/api/18816895620/mirror_demo/entries | jq
[ { "name": "Manual", "path": "Manual", "sha": "c2f18765235076b4c835b3e31262b3ee65176a75", "type": "file", "size": 12579, "content": null, "target": null, "commit": null }, { "name": "README", "path": "README", "sha": "91a29176828eba5c5598f5d4a95458e861f271ec", "type": "file", "size": 1767, "content": null, "target": null, "commit": null }, { "name": "base", "path": "base", "sha": "7adbe5698e02dba062216333d5e1d16b36ae1cbd", "type": "dir", "size": 0, "content": null, "target": null, "commit": null } ]
GET api/:login/:repo_identifier/sub_entries
curl -X GET \ -d "ref=master" \ -d "filepath=test1_create_file.rb" \ http://localhost:3000/api/18816895620/mirror_demo/sub_entries | jq
[ { "name": "build.rc", "path": "lib/build.rc", "type": "", "size": 1268, "content": null, "target": null, "url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/contents/lib/build.rc?ref=master", "html_url": "http://localhost:3003/18816895620/mirror_demo/src/branch/master/lib/build.rc", "git_url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/git/blobs/191fcf1a63b3777e2977fcede7dd5309efdd70fe", "download_url": null }, { "name": "cfg.rc", "path": "lib/cfg.rc", "type": "file", "size": 107, "content": null, "target": null, "url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/contents/lib/cfg.rc?ref=master", "html_url": "http://localhost:3003/18816895620/mirror_demo/src/branch/master/lib/cfg.rc", "git_url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/git/blobs/0b91ba0ed1c00e130c77bb9058af3787fea986a0", "download_url": "http://localhost:3003/18816895620/mirror_demo/raw/branch/master/lib/cfg.rc" }, { "name": "fn", "path": "lib/fn", "type": "dir", "size": 0, "content": null, "target": null, "url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/contents/lib/fn?ref=master", "html_url": "http://localhost:3003/18816895620/mirror_demo/src/branch/master/lib/fn", "git_url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/git/blobs/e33bd45949ef8f804471d0b6b2c59728eb445989", "download_url": null } ]
GET api/project_categories/group_list
curl -X GET http://localhost:3000/api/project_categories/group_list | jq
[ { "id": 1, "name": "大数据", "projects_count": 30 }, { "id": 2, "name": "机器学习", "projects_count": 1 }, { "id": 3, "name": "深度学习", "projects_count": 1 } ]
GET api/projects/group_type_list
curl -X GET http://localhost:3000/api/projects/group_type_list | jq
[ { "project_type": "common", "name": "开源托管项目", "projects_count": 2106 }, { "project_type": "mirror", "name": "开源镜像项目", "projects_count": 1 } ]
GET api/projects
curl -X GET \ -d "page=1" \ -d "limit=5" \ http://localhost:3000/api/projects | jq
{ "total_count": 3096, "projects": [ { "id": 1, "name": "hnfl_demo1", "description": "my first project", "visits": 0, "praises_count": 0, "forked_count": 0, "is_public": true, "mirror_url": null, "last_update_time": 1577697461, "author": { "name": "18816895620", "image_url": "avatars/User/b" }, "category": { "id": 1, "name": "大数据" }, "language": { "id": 2, "name": "C" } }, { "id": 2, "name": "hnfl_demo", "description": "my first project", "visits": 0, "praises_count": 0, "forked_count": 0, "is_public": true, "mirror_url": null, "last_update_time": 1577697403, "author": { "name": "18816895620", "image_url": "avatars/User/b" }, "category": { "id": 1, "name": "大数据" }, "language": { "id": 2, "name": "C" } }, { "id": 3, "name": "统计局", "description": "my first project", "visits": 0, "praises_count": 0, "forked_count": 0, "is_public": true, "mirror_url": null, "last_update_time": 1577415173, "author": { "name": "18816895620", "image_url": "avatars/User/b" }, "category": { "id": 1, "name": "大数据" }, "language": { "id": 2, "name": "C" } }, { "id": 5, "name": "开源同名", "description": "my first project", "visits": 0, "praises_count": 0, "forked_count": 0, "is_public": false, "mirror_url": "https://gitea.com/CasperVector/slew.git", "last_update_time": 1577346228, "author": { "name": "18816895620", "image_url": "avatars/User/b" }, "category": { "id": 1, "name": "大数据" }, "language": { "id": 2, "name": "C" } }, { "id": 7, "name": "开源支持", "description": "my first project", "visits": 0, "praises_count": 0, "forked_count": 0, "is_public": true, "mirror_url": null, "last_update_time": 1577341572, "author": { "name": "18816895620", "image_url": "avatars/User/b" }, "category": { "id": 1, "name": "大数据" }, "language": { "id": 2, "name": "C" } } ] }
GET /api/projects/:identifier/branches
curl -X GET http://localhost:3000/api/projects/mirror_demo/branches | jq
[ { "name": "develop", "user_can_push": true, "user_can_merge": true, "protected": false, "http_url": "http://localhost:3003/18816895620/mirror_demo.git", "zip_url": "http://localhost:3003/18816895620/mirror_demo/develop.zip", "tar_url": "http://localhost:3003/18816895620/mirror_demo/develop.tar.gz", "last_commit": { "id": "735674d6696bddbafa993db9c67b40c41246c77f", "message": "FIX test branch content\n", "timestamp": 1577694074, "time_from_now": "1天前" }, "author": { "login": "18816895620", "image_url": "avatars/User/b" } }, { "name": "master", "user_can_push": true, "user_can_merge": true, "protected": false, "http_url": "http://localhost:3003/18816895620/mirror_demo.git", "zip_url": "http://localhost:3003/18816895620/mirror_demo/master.zip", "tar_url": "http://localhost:3003/18816895620/mirror_demo/master.tar.gz", "last_commit": { "id": "19ac3bc45f62cc87a94b8ecce61101d8fd2dafd2", "message": "合并pull request测试\n\n该功能很不错,感谢你的建议\n", "timestamp": 1577244567, "time_from_now": "6天前" }, "author": { "login": "18816895620", "image_url": "avatars/User/b" } } ]
GET /api/:login/:repo_identifier/tags
curl -X GET http://localhost:3000/api/18816895620/mirror_demo/tags | jq
GET /api/:login/:repo_identifier/
curl -X GET \ http://localhost:3000/api/18816895620/mirror_demo | jq
{ "identifier": "mirror_demo", "project_id": 3263, "project_identifier": "mirror_demo", "praises_count": 1, "forked_count": 0, "watchers_count": 1, "branches_count": 6, "commits_count": 107, "issues_count": 0, "pull_requests_count": 0, "permission": "Manager", "mirror_url": "https://gitea.com/CasperVector/slew.git", "watched": true, "praised": true, "size": 446, "ssh_url": "jasder@localhost:18816895620/mirror_demo.git", "clone_url": "http://localhost:3003/18816895620/mirror_demo.git", "default_branch": "master", "empty": false, "full_name": "18816895620/mirror_demo", "mirror": false, "private": false, "author": { "login": "18816895620", "name": "美女", "image_url": "avatars/User/b" } }
GET /api/:login/:repo_identifier/commits
curl -X GET \ -d "sha=develop" \ -d "page=1" \ http://localhost:3000/api/18816895620/mirror_demo/commits | jq
{ "total_count": 63, "commits": [ { "sha": "19ac3bc45f62cc87a94b8ecce61101d8fd2dafd2", "message": "合并pull request测试", "timestamp": 1577244567, "time_from_now": "7天前", "author": { "name": "18816895620", "image_url": "avatars/User/b" } }, { "sha": "2b33c5f55214db41879936312ee43611406c4dbd", "message": "FIX .", "timestamp": 1577244474, "time_from_now": "7天前", "author": { "name": "18816895620", "image_url": "avatars/User/b" } } ] }
POST /api/projects/:id/praise_tread/like
curl -X POST http://localhost:3000/api/projects/3263/praise_tread/like | jq
DELETE /api/projects/:id/praise_tread/unlike
curl -X DELETE http://localhost:3000/api/projects/3263/praise_tread/unlike | jq
GET /api/projects/:id/praise_tread/check_like
curl -X GET http://localhost:3000/api/projects/3263/praise_tread/check_like | jq
GET /api/projects/:id/praise_tread
curl -X GET \ -d "page=1" \ -d "limit=5" \ http://localhost:3000/api/projects/3263/praise_tread | jq
{ "total_count": 1, "praises": [ { "name": "18816895620", "login": "18816895620", "image_url": "avatars/User/b" } ] }
POST /api/projects/:id/watchers/follow
curl -X POST http://localhost:3000/api/projects/3263/watchers/follow | jq
{ "status": 0, "message": "响应成功" }
DELETE /api/projects/:id/watchers/unfollow
curl -X DELETE http://localhost:3000//api/projects/3263/watchers/unfollow | jq
GET /api/projects/:id/watchers/check_watch
curl -X GET http://localhost:3000/api/projects/3263/watchers/check_watch | jq
GET /api/projects/:id/watchers
curl -X GET \ -d "page=1" \ -d "limit=5" \ http://localhost:3000//api/projects/3263/watchers | jq
{ "total_count": 1, "watchers": [ { "name": "18816895620", "login": "18816895620", "image_url": "avatars/User/b" } ] }
DELETE /api/:login/:repo_identifier/contents
curl -X POST \ -d 'filepath=test1_create_file1.rb' \ -d 'branch=master' \ -d 'content=提交的内容' \ -d 'message=test commit ' \ http://localhost:3000/api/18816895620/mirror_demo/contents.json | jq
{ "name": "test1_create_file12.rb", "sha": "7b70509105b587e71f5692b9e8ab70851e321f64", "size": 12, "content": "Wm5ObWMyRmtaZz09", "encoding": "base64", "commit": { "message": "good luck\n", "author": { "name": "18816895620", "email": "2456233122@qq.com", "date": "2020-01-07T03:31:20Z" }, "committer": { "name": "18816895620", "email": "2456233122@qq.com", "date": "2020-01-07T03:31:20Z" } } }
PUT /api/:login/:repo_identifier/contents/files/update
curl -X PUT \ -d 'filepath=text1.rb' \ -d 'branch=master' \ -d 'content=ruby code' \ -d 'message=更改提交信息' \ -d 'from_path=text.rb' \ -d "sha=57426eb21e4ceabdf4b206f022077e0040" \ http://localhost:3000/api/18816895620/mirror_demo/contents/files/update.json | jq
{ "name": "test1_create_file6.rb", "sha": "57426eb21e4ceabdf4b206f022257e08077e0040", "size": 16, "content": "5o+Q5Lqk55qE5YaF5a65MQ==", "encoding": "base64", "commit": { "message": "更改提交信息\n", "author": { "name": "18816895620", "email": "2456233122@qq.com", "date": "2020-01-08T07:05:15Z" }, "committer": { "name": "18816895620", "email": "2456233122@qq.com", "date": "2020-01-08T07:05:15Z" } } }
DELETE /api/:login/:repo_identifier/contents/files/delete
curl -X DELETE \ -d 'filepath=test1_create_file12.rb' \ -d 'test delete file' \ -d 'sha=7b70509105b587e71f5692b9e8ab70851e321f64' \ http://localhost:3000/api/18816895620/mirror_demo/contents/files/delete | jq
{ "commit": { "sha": "7b70509105b587e71f5692b9e8ab70851e321f64", "message": "Delete 'test1_create_file11.rb'\n", "author": { "name": "18816895620", "email": "2456233122@qq.com", "date": "2020-01-08T07:57:34Z" }, "committer": { "name": "18816895620", "email": "2456233122@qq.com", "date": "2020-01-08T07:57:34Z" } } }
<p> 基于Gitea实现的开源项目管理平台升级版 </p> <p> 本地开发流程请参考 README.md文件 </p>
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
本地开发部署步骤
1. 安装依赖包
2. 配置初始化文件
进入项目根目录执行一下命令:
3. 创建数据库
4. 导入数据表结构
5. 执行migrate迁移文件
6. 启动rails服务
7. 浏览器访问
在浏览器中输入如下地址访问:
API文档
基本介绍
开发API服务地址:
https://testgitea.trustie.net/
响应状态说明:
API接口
用户注册(通过其他平台)
示例
请求参数说明:
返回参数说明:
返回值
获取当前登录用户信息
示例
返回参数说明:
返回值
用户列表(带搜索功能)
示例
请求参数说明:
返回参数说明:
返回值
获取项目类别列表(可根据名称搜素)
示例
请求参数说明:
返回参数说明:
返回值
获取项目语言列表(可根据名称搜素)
示例
请求参数说明:
返回参数说明:
返回值
获取.gitignore模板列表(可根据名称搜素)
示例
请求参数说明:
返回参数说明:
返回值
获取开源许可证列表(可根据名称搜素)
示例
请求参数说明:
返回参数说明:
返回值
创建项目
示例
请求参数说明:
返回参数说明:
返回值
新建镜像项目
示例
请求参数说明:
返回参数说明:
返回值
项目详情
示例
请求参数说明:
返回参数说明:
返回值
编辑仓库信息
示例
返回参数说明:
返回值
修改项目信息
示例
请求参数说明:
返回参数说明:
返回值
删除项目
示例
注:只有超级管理员和项目拥有者才能删除仓库
请求参数说明:
返回参数说明:
返回值
项目添加成员
示例
请求参数说明:
返回参数说明:
返回值
项目删除成员
示例
请求参数说明:
返回参数说明:
返回值
更改项目成员角色/权限
示例
请求参数说明:
返回参数说明:
返回值
项目成员列表
示例
请求参数说明:
返回参数说明:
返回值
Fork项目
示例
请求参数说明:
返回参数说明:
返回值
获取代码目录列表
示例
请求参数说明:
返回参数说明:
返回值
获取子目录代码列表/编辑某个具体的文件
示例
请求参数说明:
返回参数说明:
返回值
项目类别列表(用于项目列表左侧导航中的项目类别列表)
示例
返回参数说明:
返回值
项目类型列表(用于项目列表左侧导航上方中的项目类型列表)
示例
返回参数说明:
返回值
项目列表
示例
请求参数说明:
返回参数说明:
返回值
获取分支列表
示例
请求参数说明:
返回参数说明:
返回值
获取版本列表
示例
请求参数说明:
返回参数说明:
返回值
仓库详情
示例
请求参数说明:
返回参数说明:
返回值
获取提交记录列表
示例
请求参数说明:
返回参数说明:
返回值
点赞
示例
请求参数说明:
返回参数说明:
返回值
取消点赞
示例
请求参数说明:
返回参数说明:
返回值
用户是否点过赞
示例
请求参数说明:
返回参数说明:
返回值
项目的点赞者列表
示例
请求参数说明:
返回参数说明:
返回值
关注(项目)
示例
请求参数说明:
返回参数说明:
返回值
取消关注
示例
请求参数说明:
返回参数说明:
返回值
用户是否关注过项目
示例
请求参数说明:
返回参数说明:
返回值
项目的关注者列表
示例
请求参数说明:
返回参数说明:
返回值
仓库新建文件
示例
请求参数说明:
返回参数说明:
返回值
更新仓库中的文件
示例
请求参数说明:
返回参数说明:
返回值
删除仓库中的文件
示例
请求参数说明:
返回参数说明:
返回值