gitea适配GaussDB开源开发任务
【摘要】 Gitea是一款极易安装,运行非常快速,安装和使用体验良好的自建 Git 服务。Gitea 是一个轻量级的 DevOps 平台软件。从开发计划到产品成型的整个软件生命周期,都能够高效而轻松的帮助团队和开发者。包括 Git 托管、代码审查、团队协作、软件包注册和 CI/CD。它与 GitHub、Bitbucket 和 GitLab 等比较类似。 Gitea 最初是从 Gogs 分支而来,几乎所...
Gitea是一款极易安装,运行非常快速,安装和使用体验良好的自建 Git 服务。Gitea 是一个轻量级的 DevOps 平台软件。从开发计划到产品成型的整个软件生命周期,都能够高效而轻松的帮助团队和开发者。包括 Git 托管、代码审查、团队协作、软件包注册和 CI/CD。它与 GitHub、Bitbucket 和 GitLab 等比较类似。 Gitea 最初是从 Gogs 分支而来,几乎所有代码都已更改。
源码地址:https://github.com/go-gitea/gitea.git
官网主页:https://gitea.com
Gitea默认不支持Gauss DB,Gitea操作数据库用的是xorm,本博客参考了 xorm适配GaussDB开源开发任务心得-云社区-华为云
1、在项目中添加包go get gitee.com/opengauss/openGauss-connector-go-pq
2、导入gaussdb商业驱动到项目
3、go.mod中替换openGauss为商业驱动:replace gitee.com/opengauss/openGauss-connector-go-pq => ./openGauss-connector-go-pq
4、在文件models\db\engine.go引入的“github.com/lib/pq”包替换成“gitee.com/opengauss/openGauss-connector-go-pq”
5、在文件models\db\sql_postgres_with_schema.go引入的“github.com/lib/pq”包替换成“gitee.com/opengauss/openGauss-connector-go-pq”
6、在文件modules\session\virtual.go 注释掉postgres的驱动注册,不然后会报错注册了2次:
panic: sql: Register called twice for driver postgres
goroutine 1 [running]:
database/sql.Register({0x42a4969, 0x8}, {0x4c5e4c0, 0x71d6520})
C:/Program Files/Go/src/database/sql/sql.go:62 +0x128
github.com/lib/pq.init.0()
o.provider = &postgres.PostgresProvider{}
Line46added
//o.provider = &postgres.PostgresProvider{}
7、在Linux机器上编译代码: TAGS="bindata" make build
8、启动:./gitea web,发现抱错信息如下: [F] Gitea is not supposed to be run as root. Sorry. If you need to use privileged TCP ports please instead use setcap and the `cap_net_bind_service` permission。这是因为gitea不允许用root用户启动,需要创建一个其他用户
9、启动后控制台输出信息如下:
安装完成后会发现配置信息写在项目的./custom/conf/app.ini里
注册的时候会发现user表的avatar报错:
cannot exec single: unexpected CommandComplete after error: pq: The null value in column "avatar" violates the not-null constraint.
avatar不能为空,我们修改字段允许为空: alter table "user" alter avatar drop NOT NULL;
还有报错user表的diff_view_style也默认不能为空,同样修改为允许为空:alter table "user" alter diff_view_style drop NOT NULL;
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)