From 256160f0cf153f4a51266cf82c0767047697f107 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Sat, 13 Dec 2025 12:11:12 +0000 Subject: [PATCH 01/19] fix: user register error --- COUNT | 2 +- pkg/aegis/db/postgres/query.go | 8 +++++--- pkg/aegis/db/sqlite/query.go | 6 +++--- templates/_footer.template.html | 2 +- templates/webinstaller/confirm.template.html | 16 +++++++++++++--- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/COUNT b/COUNT index c3c3a97..0d1d371 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.5,0 \ No newline at end of file +v0.1.5,2 \ No newline at end of file diff --git a/pkg/aegis/db/postgres/query.go b/pkg/aegis/db/postgres/query.go index e719e0c..8662f3a 100644 --- a/pkg/aegis/db/postgres/query.go +++ b/pkg/aegis/db/postgres/query.go @@ -741,10 +741,12 @@ func (dbif *PostgresAegisDatabaseInterface) RegisterUser(name string, email stri if err != nil { return nil, err } defer tx.Rollback(ctx) t := time.Now() + webp := new(model.AegisUserWebsitePreference) + webp.UseSiteWideThemeConfig = true _, err = tx.Exec(ctx, fmt.Sprintf(` -INSERT INTO %s_user(user_name, user_title, user_email, user_bio, user_website, user_reg_datetime, user_password_hash, user_status, user_2fa_config) -VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) -`, pfx), name, name, email, new(string), new(string), t, passwordHash, status, new(model.AegisUser2FAConfig)) +INSERT INTO %s_user(user_name, user_title, user_email, user_bio, user_website, user_reg_datetime, user_password_hash, user_status, user_2fa_config, user_website_preference) +VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) +`, pfx), name, name, email, new(string), new(string), t, passwordHash, status, new(model.AegisUser2FAConfig), webp) if err != nil { return nil, err } err = tx.Commit(ctx) if err != nil { return nil, err } diff --git a/pkg/aegis/db/sqlite/query.go b/pkg/aegis/db/sqlite/query.go index a49513d..60e5140 100644 --- a/pkg/aegis/db/sqlite/query.go +++ b/pkg/aegis/db/sqlite/query.go @@ -280,11 +280,11 @@ func (dbif *SqliteAegisDatabaseInterface) RegisterUser(name string, email string tx, err := dbif.connection.Begin() if err != nil { return nil, err } stmt, err := tx.Prepare(fmt.Sprintf(` -INSERT INTO %s_user(user_name, user_title, user_email, user_bio, user_website, user_password_hash, user_reg_datetime, user_status, user_2fa_config) -VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) +INSERT INTO %s_user(user_name, user_title, user_email, user_bio, user_website, user_password_hash, user_reg_datetime, user_status, user_2fa_config, user_website_preference) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) `, pfx)) if err != nil { return nil, err } - _, err = stmt.Exec(name, name, email, new(string), new(string), passwordHash, t, status, `{"email":{"enable":false}}`) + _, err = stmt.Exec(name, name, email, new(string), new(string), passwordHash, t, status, `{"email":{"enable":false}}`, `{"useSiteWideThemeConfig":true}`) if err != nil { tx.Rollback(); return nil, err } err = tx.Commit() if err != nil { tx.Rollback(); return nil, err } diff --git a/templates/_footer.template.html b/templates/_footer.template.html index 8eb506e..99180aa 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/webinstaller/confirm.template.html b/templates/webinstaller/confirm.template.html index ebbb215..3baf3ee 100644 --- a/templates/webinstaller/confirm.template.html +++ b/templates/webinstaller/confirm.template.html @@ -403,10 +403,20 @@

Confirmation

- - + + - + {{if eq .Config.FrontPage.Type "repository"}} + + + + {{else if eq .Config.FrontPage.Type "namespace"}} + + + + {{else}} + + {{end}}
FieldValue
frontPageType{{.Config.FrontPageType}}
frontPage.type{{.Config.FrontPage.Type}}
frontPageText
(Valid only for "Static file". This would be the content of static file, and would be rendered according to the file name.)
{{.Config.FrontPageContent}}
frontPage.repository{{.Config.FrontPage.Repository}}
frontPage.namespace{{.Config.FrontPage.Namespace}}
frontPage.fileContent
(Valid only for "Static file". This would be the content of static file, and would be rendered according to the file name.)
{{.Config.FrontPage.FileContent}}
From 27f6ef3bfe401cc1db05cd875e4196e9e38c3196 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Thu, 25 Dec 2025 20:05:27 +0000 Subject: [PATCH 02/19] feat: git protocol v2 for http clone --- COUNT | 2 +- VERSION | 2 +- docs/http-clone.org | 79 ++++++++++++++++++++++++++++- pkg/gitlib/transfer.go | 15 +++++- routes/controller/http-clone.go | 88 +++++++++++++++++++++++++++++++++ templates/_footer.template.html | 2 +- 6 files changed, 183 insertions(+), 5 deletions(-) diff --git a/COUNT b/COUNT index 0d1d371..074ba0b 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.5,2 \ No newline at end of file +v0.1.6-alpha,0 \ No newline at end of file diff --git a/VERSION b/VERSION index 02bf650..663138d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.1.5 \ No newline at end of file +v0.1.6-alpha \ No newline at end of file diff --git a/docs/http-clone.org b/docs/http-clone.org index eec441d..6b5a21e 100644 --- a/docs/http-clone.org +++ b/docs/http-clone.org @@ -1,7 +1,84 @@ * git clone thru http -For the most part please refer to: https://git-scm.com/book/ms/v2/Git-Internals-Transfer-Protocols +currently there are three (3) different clone-thru-http protocols: v1-dumb, v1-smart, v2. in git's documentations, v1-dumb and v1-smart are simply called "dumb" and "smart" respectively, while v2 is called "v2". both v1-smart and v2 uses a transfer format called the "pkt-line", which i imagine is the contraction of "packet line"; since they both use this pkt-line format, one might become very confused while reading git's documentations; for this reason i shall explain them in details in our own documentation. +the source of each of these names are as follows: ++ for pkt-line in general: https://git-scm.com/docs/gitprotocol-common ++ for how pkt-line is used in pack transfer: https://git-scm.com/docs/gitprotocol-pack ++ for v1-dumb and v1-smart: https://git-scm.com/docs/gitprotocol-http ++ for v2: https://git-scm.com/docs/gitprotocol-v2 +the "Git Internals" book that's available online, more specificaly [[https://git-scm.com/book/ms/v2/Git-Internals-Transfer-Protocols][this section]], describes v1-dumb and v1-smart. + +as of writing this (2025.12), Aegis uses v1-dumb mainly because both v1-smart and v2 are bloody confusing. github, however, has already deprecated v1-dumb some fourteen years ago. + +** v1-dumb + +the way v1-dumb works is that git (client's side) would download each object file directly; for any git repo git folder `$GIT_DIR`, the following paths must be available and points to their respective files: + ++ ~$GIT_DIR/info/refs~ - mappings between ref full names and their corresponding head commit id ++ ~$GIT_DIR/HEAD~ - HEAD ref; used for default cloning ++ ~$GIT_DIR/objects/~ - objects. all files under this directory must be available as well. + +these paths are the bare minimum for v1-dumb. that said, due to potential security concerns, i don't recommend accepting requests to other paths (other than ~$GIT_DIR/description~, maybe) unless things break. + +one can separate v1-dumb requests from v1-smart and v2 by checking if there's a ~service~ argument in the request url; v1-smart and v2 requests are told to must use this argument (e.g. requesting ~$GIT_DIR/info/refs?service=blah~ instead of just ~$GIT_DIR/info/refs~); to these requests, if your server only knows how to reply in v1-dumb, you should reply in v1-dumb anyway, as if the ~?service=~ part is non-existent. + +only supporting v1-dumb is not necessarily problem-free. while the official git client still supports v1-dumb, the documentation for v1 protocols do state that client must not continue if they do not support v1-dumb, which means that a client w/ no v1-dumb support is theoretically tolerated. + +v1-dumb servers should not use the response Content-Type of ~application/x-$servicename-advertisement~, where ~$servicename~ is the value of the ~?service=~ parameter we just mentioned; since servers that speak v1-smart are asked to send this header in their responses, some clients might depend on this bit of info to tell that if a server response is in v1-smart or v1-dumb. + +** pkt-line + +(the code for this part is in ~pkg/gitlib/transfer.go~.) + +a single pkt-line consists of two parts: a fixed-length length field and a data field. + +the length field is 4 bytes and is of ascii. they encode a length in hexadecimal. this length is the length of the entire pkt-line including this length field itself, so an empty pkt-line would be ~0004~. it's told in the document that you "should not" send this though. + +pkt-lines are used to transfer both text and binary data. it's said that if we use it for transferring text data we "should be" add an LF (~\n~) at the end (and making the length increase by one). whether something at a particular time is text and/or binary seems to be context-dependent; if one receives a pkt-line w/ no LF at the end while it's supposed to be a text pkt-line, we still treat it as if the LF is here anyway. + +a special instance of pkt-line exists and is the string ~0000~. it's called a "flush pkt" and what it does is seemingly different in different context. sometimes it's used as a delimiter (as we'll see in v1-smart) + +in v2, two more special instances of pkt-line are designated w/ meanings. we'll talk about this when we get to v2. these extra special instances don't occur in v1-dumb and v1-smart conversations. + +** v1-smart + +#+begin_quote +v1-smart seems to be no longer available through normal means and only available in case people are still using old version of git, see https://stackoverflow.com/questions/66743099/whats-the-difference-between-git-protocol-v1-and-v0-v2 . +#+end_quote + +as mentioned above, both v1-smart and v2 clients would GET with a ~?service=~ query. if we see services that we don't want to serve, we should return a 4xx http status code like 403 or 405. the git document says we "must" return 403, but github seems to do 405. i suppose any 4xx would've probably been fine and 405 is technically "more correct" when it comes to cases like not understanding a protocol, but we'll do 403 because the v1-smart documentation says so. (v2 documentation does not specify this case.) + +first the client would GET ~$GIT_DIR/info/refs?service=git-upload-pack~ (or any other service that there might be). ~git-upload-pack~ means the server uploading packs to your client, i.e. you cloning. confusing, i know... (similarly ~git-receive-pack~ means the server *receiving* packs from your client, i.e. you pushing.) the format seems to be as follows: + ++ one data pkt that says ~# service=$servicename~, where ~$servicename~ is the value of the ~?service=~ query argument, in this case ~git-upload-pack~. this line is a must because per git documentation client "must" check the first pkt-line is of this format. ++ one flush pkt ~0000~ ++ one /optional/ data pkt of text ~version 1~. + + the way protocol v2 is specified is through the ~Git-Protocol~ header in the request (its value would be ~version=2~ if v2 is desired), and the format of v2 response contains this version line (the text of which would be ~version 2~, naturally). apparently the possibility of some clients wanting v1-smart and passing in ~version=1~ for this header field is anticipated, so it's better to send in a corresponding ~version 1~ text when this happens. ++ one or more data pkt of the following format: + + commit id + + one whitespace + + one ref full name (~HEAD~ is a valid ref full name in this context and is the one you should get if you're cloning the "default" branch) + + one LF as per text pkt-line recommendations + the data for these, naturally, comes from ~info/refs~. the first of such id-fullname pairs would also have extra parameters, separated by the null character (~\0~). + +it's not necessarily a good idea to generate such a response by yourself, and one might want to simply use the output of command ~git upload-pack --http-backend-info-refs~. if you want to get the data this way and don't want to use ~--http-backend-info-refs~, you can also send ~0000~ to the stdin of the spawned git process. + +certain http headers must be set when replying in v1-smart. the ~Content-Type~ must be ~application/x-$servicename-advertisement~ (in the case of cloning, ~application/x-git-upload-pack-advertisement~). per git documentation you should also send in the header ~Cache-Control: no-cache~ to prevent caching. + +after this, the client would POST ~$GIT_DIR/git-upload-pack~. this would comes with a Content-Type of ~application/git-$servicename-request~ and the body would be a sequence of pkt-lines (*not* urlencoded or any other format). i will not go into the details of the protocol here because it's complicated; currently we simply call ~git upload-pack $GIT_DIR --stateless-rpc~ and pass the POST body along. + +** v2 + +one must note that newer versions of git no longer accepts ~version 1~ in response, which effectively means the canonical git implementation only speaks v1-dumb and v2. + +to coax ~git upload-pack~ into speaking v2, use the environment variable ~GIT_PROTOCOL=version=2~. + +the first two packet, i.e. the ~# service=git-upload-pack~ and the flush packet right after that is necessarily. you can directly plug in the output of ~git upload-pack $GIT_DIR --http-backend-info-refs~ *after* that. + +** notes + +the requirement about Content-Type seems to be only for ~info/refs~; all subsequent conversations seems to ignore http content-type altogether. diff --git a/pkg/gitlib/transfer.go b/pkg/gitlib/transfer.go index c90e599..bec1b33 100644 --- a/pkg/gitlib/transfer.go +++ b/pkg/gitlib/transfer.go @@ -8,15 +8,28 @@ import ( // pkt-line related. // https://git-scm.com/docs/protocol-common +var ErrPktLineEmptyReadIn = errors.New("input empty") var ErrPktLinePrematureEnd = errors.New("pkt-line ended prematurely.") func ReadPktLine(r io.Reader) (bool, string, error) { c := make([]byte, 4) n, err := io.ReadFull(r, c) + if n == 0 { return false, "", ErrPktLineEmptyReadIn } if err != nil { return false, "", err } if n < 4 { return false, "", ErrPktLinePrematureEnd } ss := (int(charHexToDigit(c[0]))<<12) | (int(charHexToDigit(c[1]))<<8) | (int(charHexToDigit(c[2]))<<4) | (int(charHexToDigit(c[3]))) - if ss == 0 { return true, "", nil } + switch ss { + case 0: // flush + return true, "0000", nil + case 1: // v2 delimiter packet (see docs/http-clone.org) + return true, "0001", nil + case 2: // v2 response end packet (see docs/http-clone.org) + return true, "0002", nil + case 3: + // not specified (but we're writing this just in case git uses + // it for something new) + return true, "0003", nil + } data := make([]byte, ss) n, err = io.ReadFull(r, data) if n != ss { return false, "", ErrPktLinePrematureEnd } diff --git a/routes/controller/http-clone.go b/routes/controller/http-clone.go index c24fef6..06eaa82 100644 --- a/routes/controller/http-clone.go +++ b/routes/controller/http-clone.go @@ -1,8 +1,12 @@ package controller import ( + "bytes" + "fmt" + "io" "net/http" "os" + "os/exec" "path" "github.com/bctnry/aegis/pkg/aegis" @@ -12,6 +16,12 @@ import ( . "github.com/bctnry/aegis/routes" ) +func printGitError(w io.Writer, s string) { + ss, _ := gitlib.ToPktLine(fmt.Sprintf("ERR %s\n", s)) + fmt.Fprint(w, ss) +} + + // info/refs // HEAD // objects/ @@ -51,6 +61,36 @@ func bindHttpCloneController(ctx *RouterContext) { w.Write([]byte("404 Not Found")) return } + // see docs/http-clone.org. + if (r.URL.Query().Has("service")) { + switch r.URL.Query().Get("service") { + case "git-upload-pack": + cmd := exec.Command("git", "upload-pack", repo.LocalPath, "--http-backend-info-refs") + cmd.Dir = repo.LocalPath + protocol := r.Header.Get("Git-Protocol") + if protocol == "" { protocol = "version=2" } + cmd.Env = append(cmd.Env, fmt.Sprintf("GIT_PROTOCOL=%s", protocol)) + stdout := new(bytes.Buffer) + cmd.Stdout = stdout + err := cmd.Run() + if err != nil { + w.WriteHeader(500) + printGitError(w, err.Error()) + return + } + w.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") + w.Header().Set("Cache-Control", "no-cache, max-age=0, must-revalidate") + w.WriteHeader(200) + fmt.Fprint(w, "001e# service=git-upload-pack\n") + fmt.Fprint(w, "0000") + w.Write(stdout.Bytes()) + default: + w.WriteHeader(403) + printGitError(w, "Not supported service.") + } + return + } + // v1-dumb rr := repo.Repository.(*gitlib.LocalGitRepository) p := path.Join(rr.GitDirectoryPath, "info", r.PathValue("p")) s, err := os.ReadFile(p) @@ -60,6 +100,54 @@ func bindHttpCloneController(ctx *RouterContext) { } w.Write(s) })) + http.HandleFunc("POST /repo/{repoName}/git-upload-pack", WithLog(func(w http.ResponseWriter, r *http.Request) { + if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { + w.WriteHeader(403) + w.Write([]byte("Service not available right now.")) + return + } + rfn := r.PathValue("repoName") + if !model.ValidRepositoryName(rfn) { + w.WriteHeader(404) + w.Write([]byte("Repository not found.")) + return + } + _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) + if err == routes.ErrNotFound { + w.WriteHeader(404) + w.Write([]byte("Repository not found.")) + return + } + if err != nil { + ctx.ReportInternalError(err.Error(), w, r) + return + } + if repo.Type != model.REPO_TYPE_GIT { + w.WriteHeader(403) + w.Write([]byte("Repository not Git.")) + return + } + isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC + isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC + isRepoArchived := repo.Status == model.REPO_ARCHIVED + if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { + w.WriteHeader(404) + w.Write([]byte("404 Not Found")) + return + } + w.Header().Set("Content-Type", "application/x-git-upload-pack-response") + w.Header().Set("Cache-Control", "no-cache, max-age=0, must-revalidate") + w.WriteHeader(200) + cmd := exec.Command("git", "upload-pack", repo.LocalPath, "--stateless-rpc") + cmd.Stdin = r.Body + protocol := r.Header.Get("Git-Protocol") + if protocol == "" { protocol = "version=2" } + cmd.Env = append(cmd.Env, fmt.Sprintf("GIT_PROTOCOL=%s", protocol)) + buf := new(bytes.Buffer) + cmd.Stdout = buf + cmd.Run() + io.Copy(w, buf) + })) http.HandleFunc("GET /repo/{repoName}/HEAD", WithLog(func(w http.ResponseWriter, r *http.Request) { if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { ctx.ReportForbidden("", w, r) diff --git a/templates/_footer.template.html b/templates/_footer.template.html index 99180aa..b992900 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file From 4e84b42f8c7770a17cfe88345ea2e1f57d2173e6 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Fri, 26 Dec 2025 10:14:57 +0000 Subject: [PATCH 03/19] fix: ui fixes --- COUNT | 2 +- static/style.css | 25 +++++++++- templates/_footer.template.html | 2 +- templates/commit-history.template.html | 46 +++++++++---------- templates/file-image.template.html | 11 +++-- templates/file-text.template.html | 10 ++-- .../pull-request-list.template.html | 28 ++++++++--- templates/repository.template.html | 13 +++--- 8 files changed, 88 insertions(+), 49 deletions(-) diff --git a/COUNT b/COUNT index 074ba0b..a631cb5 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,0 \ No newline at end of file +v0.1.6-alpha,28 \ No newline at end of file diff --git a/static/style.css b/static/style.css index 619d317..0655646 100644 --- a/static/style.css +++ b/static/style.css @@ -1,6 +1,7 @@ :root { --shade-degree-0: color(from var(--foreground-color) srgb r g b / 0.2); --shade-degree-1: color(from var(--foreground-color) srgb r g b / 0.4); + --shade-degree-half: color(from var(--foreground-color) srgb r g b / 0.5); --shade-degree-2: color(from var(--foreground-color) srgb r g b / 0.6); --shade-degree-3: color(from var(--foreground-color) srgb r g b / 0.8); --file-list-height: 1rem; @@ -152,6 +153,24 @@ hr { } .commit-history-item-message { margin-top: 1rem; +} +.commit-history-table { + +} +.commit-history-table td { + vertical-align: top; +} +.commit-history-table td:nth-of-type(1) { /* commit id */ + width: 7rem; +} +.commit-history-table td:nth-of-type(2) { + width: 160q; +} +.commit-history-table td:nth-of-type(3) { + width: 360q; +} +.commit-history-table td:nth-of-type(1) { + } /* ======================================================== */ @@ -360,7 +379,9 @@ main { display: flex; } .left-side { - max-width: 30%; + max-width: 240q; + min-width: 240q; + width: 240q; flex-grow: 1; padding-right: 2rem; } @@ -560,7 +581,7 @@ form td { .precise-time { - color: #ffffff7f; + color: var(--shade-degree-half); } diff --git a/templates/_footer.template.html b/templates/_footer.template.html index b992900..ad2b7c5 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/commit-history.template.html b/templates/commit-history.template.html index eadb808..e342312 100644 --- a/templates/commit-history.template.html +++ b/templates/commit-history.template.html @@ -27,36 +27,36 @@
- Commit History: + Commit History
- -
{{if eq (len .CommitHistory) 0}} There are no older commits. {{else}} - {{range .CommitHistory}} - {{$authorUserName := resolveEmailToUsername $emailUserMapping .AuthorInfo.AuthorEmail}} - {{$committerUserName := resolveEmailToUsername $emailUserMapping .CommitterInfo.AuthorEmail}} -
- {{slice .Id 0 8}} by {{$authorUserName}} @ {{toFuzzyTime .AuthorInfo.Time}} {{.AuthorInfo.Time}} - Commit {{.Id}} (Diff) (Tree) (Full History)
- Author: - {{.AuthorInfo.AuthorName}} - ({{.AuthorInfo.AuthorEmail}}) - @ {{toFuzzyTime .AuthorInfo.Time}} {{.AuthorInfo.Time}}
- Committer: - {{.CommitterInfo.AuthorName}} - ({{.CommitterInfo.AuthorEmail}}) - @ {{toFuzzyTime .CommitterInfo.Time}} {{.CommitterInfo.Time}}
- Message:

{{.CommitMessage}}

- {{if gt (len .Signature) 0}} -
Commit Signature
{{.Signature}}
- {{end}} -
- {{end}} + + + + + + + + + {{range .CommitHistory}} + {{$authorUserName := resolveEmailToUsername $emailUserMapping .AuthorInfo.AuthorEmail}} + {{$committerUserName := resolveEmailToUsername $emailUserMapping .CommitterInfo.AuthorEmail}} + + + + + + + {{end}} + +
commitdatetimeauthormessage
{{slice .Id 0 8}}{{toFuzzyTime .AuthorInfo.Time}} + {{.AuthorInfo.AuthorName}} + {{firstLine .CommitMessage}}
{{end}}
Older commit
diff --git a/templates/file-image.template.html b/templates/file-image.template.html index 943c137..73aae85 100644 --- a/templates/file-image.template.html +++ b/templates/file-image.template.html @@ -11,6 +11,12 @@
{{template "_header-nav" .}} {{template "_repo-header" .}} + +
+ {{if .CommitInfo}}{{template "_commit-info" .CommitInfo}}{{end}} + {{if .TagInfo}}{{template "_tag-info" .TagInfo}}{{end}} +
+ {{if .ComparisonInfo}} {{if eq .LoginInfo.UserName .Repository.Owner}} {{template "_comparison-info" .ComparisonInfo}} @@ -18,11 +24,6 @@ {{end}}
-
- {{if .CommitInfo}}{{template "_commit-info" .CommitInfo}}{{end}} - {{if .TagInfo}}{{template "_tag-info" .TagInfo}}{{end}} -
-
diff --git a/templates/file-text.template.html b/templates/file-text.template.html index 2f35726..9e17c89 100644 --- a/templates/file-text.template.html +++ b/templates/file-text.template.html @@ -11,17 +11,19 @@
{{template "_header-nav" .}} {{template "_repo-header" .}} + +
+ {{if .CommitInfo}}{{template "_commit-info" .CommitInfo}}{{end}} + {{if .TagInfo}}{{template "_tag-info" .TagInfo}}{{end}} +
{{if .ComparisonInfo}} {{if eq .LoginInfo.UserName .Repository.Owner}} {{template "_comparison-info" .ComparisonInfo}} {{end}} {{end}} +
-
- {{if .CommitInfo}}{{template "_commit-info" .CommitInfo}}{{end}} - {{if .TagInfo}}{{template "_tag-info" .TagInfo}}{{end}} -

diff --git a/templates/pull-request/pull-request-list.template.html b/templates/pull-request/pull-request-list.template.html index 017c10c..3f6b1ea 100644 --- a/templates/pull-request/pull-request-list.template.html +++ b/templates/pull-request/pull-request-list.template.html @@ -41,13 +41,27 @@ {{if or (not .PullRequestList) (le (len .PullRequestList) 0) }} There is no pull request for this repository. {{else}} - {{range .PullRequestList}} -
- {{end}} + + + + + + + + + {{range .PullRequestList}} + + + + + + + {{end}} + +
idstatusbytopic
{{.PRId}}{{if eq .Status 1}}OPEN{{else if eq .Status 2}}MERGED{{else if eq .Status 3}}DISCARDED{{end}}{{.Author}} + {{.Title}}
+ @ {{toFuzzyTime .Timestamp}} {{toPreciseTime .Timestamp}} +
{{end}} diff --git a/templates/repository.template.html b/templates/repository.template.html index 2cd0e69..a06304d 100644 --- a/templates/repository.template.html +++ b/templates/repository.template.html @@ -34,8 +34,8 @@ {{end}} - {{end}} + {{end}}
@@ -51,8 +51,8 @@ {{end}} - {{end}} + {{end}}
@@ -71,17 +71,18 @@ {{template "_tree-file-list" .TreeFileList}} {{end}} -
- {{if gt (len .ReadmeString) 0}}{{rawHTML .ReadmeString}}{{else}} + {{if gt (len .ReadmeString) 0}} +
{{rawHTML .ReadmeString}}
+ {{else}} {{if and (eq (len .Repository.Repository.BranchIndex) 0) (eq (len .Repository.Repository.TagIndex) 0)}}

This repository seems to be completely empty. If you've just created this repository, you can follow the instructions below to upload a local Git repository here:

git remote add origin {{getRepoSSH .Config .Repository}}
 git push -u origin
- {{else}}

This repository has no README text.

{{end}} + {{else}} +

This repository has no README text.

{{end}} {{end}} -
From 9e6f045b0ba7722e3465d77fd4dd450c6519e029 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Fri, 26 Dec 2025 18:57:48 +0000 Subject: [PATCH 04/19] fix: new pull request ui stuck on empty fork --- COUNT | 2 +- routes/controller/repo-pull-request.go | 2 ++ templates/_footer.template.html | 2 +- templates/pull-request/new-pull-request.model.go | 1 + .../pull-request/new-pull-request.template.html | 15 ++++++--------- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/COUNT b/COUNT index a631cb5..945a535 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,28 \ No newline at end of file +v0.1.6-alpha,34 \ No newline at end of file diff --git a/routes/controller/repo-pull-request.go b/routes/controller/repo-pull-request.go index 560951f..ba2ac36 100644 --- a/routes/controller/repo-pull-request.go +++ b/routes/controller/repo-pull-request.go @@ -269,6 +269,7 @@ func bindRepositoryPullRequestController(ctx *RouterContext) { Repository: s, LoginInfo: rc.LoginInfo, ProviderRepository: fr, + Stage: "repo", })) } else { _, _, _, provider, err := rc.ResolveRepositoryFullName(providerRepositoryName) @@ -296,6 +297,7 @@ func bindRepositoryPullRequestController(ctx *RouterContext) { ReceiverBranch: receiverBranch, ChosenProviderRepository: provider, ProviderBranchList: branchNameList, + Stage: "branch", })) } }, diff --git a/templates/_footer.template.html b/templates/_footer.template.html index ad2b7c5..4fa5709 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/pull-request/new-pull-request.model.go b/templates/pull-request/new-pull-request.model.go index 643fd98..fba07ce 100644 --- a/templates/pull-request/new-pull-request.model.go +++ b/templates/pull-request/new-pull-request.model.go @@ -11,6 +11,7 @@ type RepositoryNewPullRequestTemplateModel struct { RepoHeaderInfo *RepoHeaderTemplateModel LoginInfo *LoginInfoModel ErrorMsg string + Stage string ReceiverBranch string ProviderRepository []*model.Repository ChosenProviderRepository *model.Repository diff --git a/templates/pull-request/new-pull-request.template.html b/templates/pull-request/new-pull-request.template.html index ba50baa..40e0d02 100644 --- a/templates/pull-request/new-pull-request.template.html +++ b/templates/pull-request/new-pull-request.template.html @@ -24,8 +24,8 @@
Create New Pull Request - {{if .ProviderRepository}} - {{if gt (len .ProviderRepository) 0}} + {{if eq .Stage "repo"}} + {{if and (.ProviderRepository) (gt (len .ProviderRepository) 0)}}
@@ -56,14 +56,10 @@ {{else}}

There is no repository available for creating a pull request. Create a fork and push your changes to your fork first.

{{end}} - {{else}} - {{if not .ChosenProviderRepository}} -

There is no repository available for creating a pull request. Create a fork and push your changes to your fork first.

{{end}} - {{end}} - - {{if .ProviderBranchList}} - {{if gt (len .ProviderBranchList) 0}} + + {{if eq .Stage "branch"}} + {{if and .ProviderBranchList (gt (len .ProviderBranchList) 0)}} @@ -100,6 +96,7 @@ {{else}}

There is no branch in this provider repository for creating a pull request.

+

Go back and select other repositories

{{end}} {{end}} From 5db60ac75a4b07482e6b328a623400df2704fa4d Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Sat, 27 Dec 2025 00:39:00 +0000 Subject: [PATCH 05/19] fix: fork sync for empty repo --- COUNT | 2 +- docs/fork.org | 14 +++++- pkg/gitlib/repository.go | 24 ++++++++- routes/aux.go | 12 +++++ routes/controller/branch.go | 12 ++++- routes/controller/repository.go | 55 ++++++++++++++++++++- templates/_comparison-info.template.html | 13 ----- templates/_comparison-notice.template.html | 14 ++++++ templates/_footer.template.html | 2 +- templates/file-image.template.html | 13 +++-- templates/file-text.template.html | 13 +++-- templates/firstLine.func.go | 14 ++++++ templates/isFork.func.go | 10 ++++ templates/repository.model.go | 1 + templates/repository.template.html | 8 +++ templates/shouldShowSynchronizeLink.func.go | 12 +++++ templates/tree.template.html | 12 +++-- 17 files changed, 194 insertions(+), 37 deletions(-) delete mode 100644 templates/_comparison-info.template.html create mode 100644 templates/_comparison-notice.template.html create mode 100644 templates/firstLine.func.go create mode 100644 templates/isFork.func.go create mode 100644 templates/shouldShowSynchronizeLink.func.go diff --git a/COUNT b/COUNT index 945a535..bae1c4e 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,34 \ No newline at end of file +v0.1.6-alpha,58 \ No newline at end of file diff --git a/docs/fork.org b/docs/fork.org index ef21351..6f5d168 100644 --- a/docs/fork.org +++ b/docs/fork.org @@ -27,9 +27,11 @@ see [[./pull-request.org]] first we must =git-fetch=: #+begin_src sh -git fetch [remote] +git fetch [remote] --tags #+end_src +*** to sync a certain branch + =git-merge-base= is used to check if one can be fast-forwarded to another: #+begin_src sh @@ -48,4 +50,12 @@ after confirming that we indeed can fast forward we simply =git-update-ref=: git update-ref refs/heads/[branch-a] [remote-b]/[branch-b] #+end_src - +*** to sync an empty fork + +suppose the following situation: a repository A is created; a fork is created from A; new data is then pushed to repository A afterh creating the fork. we cannot ~merge-base~ since there's no commit to merge. we must do the following: + ++ ~git fetch [remote] --tags~ ++ ~git ls-remote --branches --tags [remote] -q~ ++ for each branches and tags: ~git update-ref [ref-full-name] [commit-id]~ + + diff --git a/pkg/gitlib/repository.go b/pkg/gitlib/repository.go index 6a3f9fe..2a5b0e7 100644 --- a/pkg/gitlib/repository.go +++ b/pkg/gitlib/repository.go @@ -288,8 +288,8 @@ func (gr LocalGitRepository) CheckIfCanFastForward(branch string, remoteName str return base == strings.TrimSpace(string(f1)), nil } -func (gr LocalGitRepository) FetchRemote(branch string, remote string) error { - cmd1 := exec.Command("git", "fetch", remote) +func (gr LocalGitRepository) FetchRemote(remote string) error { + cmd1 := exec.Command("git", "fetch", remote, "--tags") cmd1.Dir = gr.GitDirectoryPath stderrBuf := new(bytes.Buffer) cmd1.Stderr = stderrBuf @@ -300,6 +300,26 @@ func (gr LocalGitRepository) FetchRemote(branch string, remote string) error { return nil } +func (gr LocalGitRepository) SyncEmptyRepositoryFromRemote(remote string) error { + err := gr.FetchRemote(remote) + if err != nil { return err } + cmd1 := exec.Command("git", "ls-remote", "--branches", "--tags", remote) + cmd1.Dir = gr.GitDirectoryPath + stdout := new(bytes.Buffer) + cmd1.Stdout = stdout + err = cmd1.Run() + if err != nil { return err } + for v := range strings.SplitSeq(stdout.String(), "\n") { + p := strings.Split(v, "\t") + if len(p) < 2 { continue } + cmd2 := exec.Command("git", "update-ref", p[1], p[0]) + cmd2.Dir = gr.GitDirectoryPath + err = cmd2.Run() + if err != nil { return err } + } + return nil +} + func (gr LocalGitRepository) UpdateRef(branch string, targetId string) error { cmd := exec.Command("git", "update-ref", fmt.Sprintf("refs/heads/%s", branch), targetId) cmd.Dir = gr.GitDirectoryPath diff --git a/routes/aux.go b/routes/aux.go index 9689e82..2e88fad 100644 --- a/routes/aux.go +++ b/routes/aux.go @@ -106,6 +106,18 @@ func GenerateLoginInfoModel(ctx *RouterContext, r *http.Request) (*templates.Log } res, err := ctx.SessionInterface.VerifySession(un, s.Value) if err != nil { return nil, err } + if !res { + return &templates.LoginInfoModel{ + LoggedIn: loggedIn, + UserName: "", + UserFullName: "", + UserEmail: "", + IsOwner: false, + IsSettingMember: false, + IsAdmin: false, + IsSuperAdmin: false, + }, nil + } u, err := ctx.DatabaseInterface.GetUserByName(un) if err != nil { return nil, err } return &templates.LoginInfoModel{ diff --git a/routes/controller/branch.go b/routes/controller/branch.go index 5315a21..a351e1d 100644 --- a/routes/controller/branch.go +++ b/routes/controller/branch.go @@ -226,9 +226,17 @@ func bindBranchController(ctx *RouterContext) { } isFastForwardRequest := r.URL.Query().Has("ff") - if isFastForwardRequest && compareInfo != nil && rc.LoginInfo.IsOwner { + if isFastForwardRequest && compareInfo != nil { + if !rc.LoginInfo.IsOwner { + ctx.ReportRedirect(fmt.Sprintf("/repo/%s", rfn), 0, + "Not enouhg privilege", + "Your user account seems to not have enough privilege for this action.", + w, r, + ) + return + } if len(compareInfo.ARevList) > 0 && len(compareInfo.BRevList) <= 0 { - err = rr.FetchRemote(branchName, "origin") + err = rr.FetchRemote("origin") if err != nil { rc.ReportInternalError(fmt.Sprintf("Failed to sync repository: %s", err), w, r) return diff --git a/routes/controller/repository.go b/routes/controller/repository.go index c59d7c2..7070bac 100644 --- a/routes/controller/repository.go +++ b/routes/controller/repository.go @@ -44,7 +44,7 @@ func bindRepositoryController(ctx *RouterContext) { return } - if rc.Config.OperationMode != aegis.OP_MODE_NORMAL { + if rc.Config.OperationMode == aegis.OP_MODE_NORMAL { rc.LoginInfo.IsOwner = s.Owner == rc.LoginInfo.UserName || ns.Owner == rc.LoginInfo.UserName } if !rc.Config.IsInPlainMode() && s.Status == model.REPO_NORMAL_PRIVATE { @@ -82,6 +82,13 @@ func bindRepositoryController(ctx *RouterContext) { var cobj *gitlib.CommitObject var treeObjList []gitlib.TreeObjectItem var permaLink string = "" + var isFork bool = false + var upstream model.LocalRepository + var compareInfo *gitlib.BranchComparisonInfo = nil + if len(s.ForkOriginName) > 0 || len(s.ForkOriginNamespace) > 0 { + isFork = true + } + emailUserMap := make(map[string]string, 0) repoHeaderInfo = GenerateRepoHeader("", "") @@ -98,7 +105,9 @@ func bindRepositoryController(ctx *RouterContext) { if !ok { br, ok = rr.BranchIndex["main"] } if !ok { k := auxfuncs.SortedKeys(rr.BranchIndex) - if len(k) <= 0 { goto findingMajorBranchDone; } + if len(k) <= 0 { + goto findingMajorBranchDone; + } br = rr.BranchIndex[k[0]]; } repoHeaderInfo.TypeStr = "branch" @@ -187,8 +196,49 @@ func bindRepositoryController(ctx *RouterContext) { readmeString = bluemonday.UGCPolicy().Sanitize(readmeString) readmeString = fmt.Sprintf("
%s
", readmeString) } + // resolve branch comparison info... + if isFork { + upstreamPath := path.Join(ctx.Config.GitRoot, s.ForkOriginNamespace, s.ForkOriginName) + upstream, _ = model.CreateLocalRepository(model.REPO_TYPE_GIT, s.ForkOriginNamespace, s.ForkOriginName, upstreamPath) + remoteName := fmt.Sprintf("%s/%s", s.Namespace, s.Name) + compareInfo, err = upstream.(*gitlib.LocalGitRepository).CompareBranchWithRemote(br.Name, remoteName) + } findingMajorBranchDone: + isFastForwardRequest := r.URL.Query().Has("ff") + if isFastForwardRequest { + if !rc.LoginInfo.IsOwner { + ctx.ReportRedirect(fmt.Sprintf("/repo/%s", rfn), 0, + "Not enouhg privilege", + "Your user account seems to not have enough privilege for this action.", + w, r, + ) + return + } + if compareInfo != nil { + err = rr.FetchRemote("origin") + if err != nil { + rc.ReportInternalError(fmt.Sprintf("Failed to sync repository: %s", err), w, r) + return + } + if len(compareInfo.ARevList) > 0 && len(compareInfo.BRevList) <= 0 { + err = rr.UpdateRef(br.Name, compareInfo.ARevList[0]) + if err != nil { + rc.ReportInternalError(fmt.Sprintf("Failed to sync repository: %s", err), w, r) + return + } + } + } else { + err = rr.SyncEmptyRepositoryFromRemote("origin") + if err != nil { + rc.ReportInternalError(fmt.Sprintf("Failed to sync repository: %s", err), w, r) + return + } + } + rc.ReportRedirect(fmt.Sprintf("/repo/%s/", rfn), 3, "Repository Synced", "The repository has been successfully fast-forwarded with its upstream.", w, r) + return + } + LogTemplateError(rc.LoadTemplate("repository").Execute(w, templates.RepositoryModel{ Config: rc.Config, Repository: s, @@ -200,6 +250,7 @@ func bindRepositoryController(ctx *RouterContext) { MajorBranchPermaLink: permaLink, TreeFileList: treeFileList, CommitInfo: commitInfo, + ComparisonInfo: compareInfo, })) }, )) diff --git a/templates/_comparison-info.template.html b/templates/_comparison-info.template.html deleted file mode 100644 index 18de895..0000000 --- a/templates/_comparison-info.template.html +++ /dev/null @@ -1,13 +0,0 @@ -{{define "_comparison-info"}} -
-

Fork Notice: - {{if gt (len .BRevList) 0}} - This repository is {{len .BRevList}} commits beyond {{if gt (len .ARevList) 0}} and {{len .ARevList}} commits behind {{end}}upstream. - {{else if gt (len .ARevList) 0}} - This repository is {{len .ARevList}} commits behind upstream. Sync now. - {{else}} - This repository is in sync with upstream. - {{end}}

-
-{{end}} - diff --git a/templates/_comparison-notice.template.html b/templates/_comparison-notice.template.html new file mode 100644 index 0000000..e83b562 --- /dev/null +++ b/templates/_comparison-notice.template.html @@ -0,0 +1,14 @@ +{{define "_comparison-notice"}} +Fork Notice: + {{if gt (len .BRevList) 0}} + This repository is {{len .BRevList}} commits beyond {{if gt (len .ARevList) 0}} and {{len .ARevList}} commits behind {{end}}upstream. + {{else if gt (len .ARevList) 0}} + This repository is {{len .ARevList}} commits behind upstream. + {{else if .}} + This repository is in sync with upstream. + {{else}} + This repository seems to be empty. + {{end}} + +{{end}} + diff --git a/templates/_footer.template.html b/templates/_footer.template.html index 4fa5709..cdef6a4 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/file-image.template.html b/templates/file-image.template.html index 73aae85..f164038 100644 --- a/templates/file-image.template.html +++ b/templates/file-image.template.html @@ -16,11 +16,14 @@ {{if .CommitInfo}}{{template "_commit-info" .CommitInfo}}{{end}} {{if .TagInfo}}{{template "_tag-info" .TagInfo}}{{end}} - - {{if .ComparisonInfo}} - {{if eq .LoginInfo.UserName .Repository.Owner}} - {{template "_comparison-info" .ComparisonInfo}} - {{end}} + + {{if isFork .Repository}} +
+ {{template "_comparison-notice" .ComparisonInfo}} + {{if shouldShowSynchronizeLink .LoginInfo .ComparisonInfo}} + Synchronize now. + {{end}} +
{{end}} diff --git a/templates/file-text.template.html b/templates/file-text.template.html index 9e17c89..42bc6f1 100644 --- a/templates/file-text.template.html +++ b/templates/file-text.template.html @@ -16,12 +16,15 @@ {{if .CommitInfo}}{{template "_commit-info" .CommitInfo}}{{end}} {{if .TagInfo}}{{template "_tag-info" .TagInfo}}{{end}} - {{if .ComparisonInfo}} - {{if eq .LoginInfo.UserName .Repository.Owner}} - {{template "_comparison-info" .ComparisonInfo}} - {{end}} + + {{if isFork .Repository}} +
+ {{template "_comparison-notice" .ComparisonInfo}} + {{if shouldShowSynchronizeLink .LoginInfo .ComparisonInfo}} + Synchronize now. + {{end}} +
{{end}} - diff --git a/templates/firstLine.func.go b/templates/firstLine.func.go new file mode 100644 index 0000000..3dc4ae0 --- /dev/null +++ b/templates/firstLine.func.go @@ -0,0 +1,14 @@ +//go:build ignore +package templates + +import "strings" + +func(s string) string { + a := strings.SplitN(s, "\n", 2) + if (len(a) >= 1) { + return a[0] + } else { + return "" + } +} + diff --git a/templates/isFork.func.go b/templates/isFork.func.go new file mode 100644 index 0000000..3882906 --- /dev/null +++ b/templates/isFork.func.go @@ -0,0 +1,10 @@ +//go:build ignore +package templates + +import "github.com/bctnry/aegis/pkg/model" + +func(s *model.Repository) bool { + return len(s.ForkOriginNamespace) > 0 && len(s.ForkOriginName) >0 +} + + diff --git a/templates/repository.model.go b/templates/repository.model.go index 029e704..41bfb71 100644 --- a/templates/repository.model.go +++ b/templates/repository.model.go @@ -16,4 +16,5 @@ type RepositoryModel struct{ ReadmeString string TreeFileList *TreeFileListTemplateModel CommitInfo *CommitInfoTemplateModel + ComparisonInfo *gitlib.BranchComparisonInfo } diff --git a/templates/repository.template.html b/templates/repository.template.html index a06304d..6b1d8ad 100644 --- a/templates/repository.template.html +++ b/templates/repository.template.html @@ -15,6 +15,14 @@ {{if .CommitInfo}} {{template "_commit-info" .CommitInfo}} {{end}} + {{if isFork .Repository}} +
+ {{template "_comparison-notice" .ComparisonInfo}} + {{if shouldShowSynchronizeLink .LoginInfo .ComparisonInfo}} + Synchronize now. + {{end}} +
+ {{end}}
diff --git a/templates/shouldShowSynchronizeLink.func.go b/templates/shouldShowSynchronizeLink.func.go new file mode 100644 index 0000000..fd7e453 --- /dev/null +++ b/templates/shouldShowSynchronizeLink.func.go @@ -0,0 +1,12 @@ +//go:build ignore +package templates + +import "github.com/bctnry/aegis/pkg/gitlib" + +func(s *LoginInfoModel, ci *gitlib.BranchComparisonInfo) bool { + if !s.LoggedIn { return false } + if !s.IsOwner { return false } + if len(ci.ARevList) > 0 && len(ci.BRevList) <= 0 { return true } + return false +} + diff --git a/templates/tree.template.html b/templates/tree.template.html index 98557d2..4b4121c 100644 --- a/templates/tree.template.html +++ b/templates/tree.template.html @@ -15,10 +15,14 @@ {{if .CommitInfo}}{{template "_commit-info" .CommitInfo}}{{end}} {{if .TagInfo}}{{template "_tag-info" .TagInfo}}{{end}} - {{if .ComparisonInfo}} - {{if eq .LoginInfo.UserName .Repository.Owner}} - {{template "_comparison-info" .ComparisonInfo}} - {{end}} + + {{if isFork .Repository}} +
+ {{template "_comparison-notice" .ComparisonInfo}} + {{if shouldShowSynchronizeLink .LoginInfo .ComparisonInfo}} + Synchronize now. + {{end}} +
{{end}}
From 612c178aa3ca9d16d66a7e5ba3d49cf1edbbddf7 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Sat, 27 Dec 2025 00:44:27 +0000 Subject: [PATCH 06/19] fix: remove syntax coloring for plaintext --- COUNT | 2 +- routes/controller/aux.go | 1 + templates/_footer.template.html | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/COUNT b/COUNT index bae1c4e..f0ebcd4 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,58 \ No newline at end of file +v0.1.6-alpha,59 \ No newline at end of file diff --git a/routes/controller/aux.go b/routes/controller/aux.go index b187432..cd37acb 100644 --- a/routes/controller/aux.go +++ b/routes/controller/aux.go @@ -186,6 +186,7 @@ func codeTypeDiscern(s string) string { case ".tex": return "TeX" case ".toml": return "TOML" case ".ts": return "TypeScript" + case ".txt": return "plaintext" case ".typst": return "Typst" case ".vala": return "Vala" case ".vue": return "Vue" diff --git a/templates/_footer.template.html b/templates/_footer.template.html index cdef6a4..c16041d 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file From 94d1841aabdc76d3629bb475030594703cd84dc4 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Sat, 27 Dec 2025 01:11:53 +0000 Subject: [PATCH 07/19] refactor: UseMiddleware for http-clone --- COUNT | 2 +- routes/controller/http-clone.go | 410 ++++++++++++++++---------------- templates/_footer.template.html | 2 +- 3 files changed, 211 insertions(+), 203 deletions(-) diff --git a/COUNT b/COUNT index f0ebcd4..6504c90 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,59 \ No newline at end of file +v0.1.6-alpha,60 \ No newline at end of file diff --git a/routes/controller/http-clone.go b/routes/controller/http-clone.go index 06eaa82..413b477 100644 --- a/routes/controller/http-clone.go +++ b/routes/controller/http-clone.go @@ -30,207 +30,215 @@ func printGitError(w io.Writer, s string) { // will report 404 for all private repositories. func bindHttpCloneController(ctx *RouterContext) { - http.HandleFunc("GET /repo/{repoName}/info/{p...}", WithLog(func(w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { - ctx.ReportForbidden("", w, r) - return - } - rfn := r.PathValue("repoName") - if !model.ValidRepositoryName(rfn) { - ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) - return - } - _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) - if err == routes.ErrNotFound { - ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) - return - } - if err != nil { - ctx.ReportInternalError(err.Error(), w, r) - return - } - if repo.Type != model.REPO_TYPE_GIT { - ctx.ReportNormalError("The repository you have requested isn't a Git repository.", w, r) - return - } - isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC - isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC - isRepoArchived := repo.Status == model.REPO_ARCHIVED - if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { - w.WriteHeader(404) - w.Write([]byte("404 Not Found")) - return - } - // see docs/http-clone.org. - if (r.URL.Query().Has("service")) { - switch r.URL.Query().Get("service") { - case "git-upload-pack": - cmd := exec.Command("git", "upload-pack", repo.LocalPath, "--http-backend-info-refs") - cmd.Dir = repo.LocalPath - protocol := r.Header.Get("Git-Protocol") - if protocol == "" { protocol = "version=2" } - cmd.Env = append(cmd.Env, fmt.Sprintf("GIT_PROTOCOL=%s", protocol)) - stdout := new(bytes.Buffer) - cmd.Stdout = stdout - err := cmd.Run() - if err != nil { - w.WriteHeader(500) - printGitError(w, err.Error()) - return + http.HandleFunc("GET /repo/{repoName}/info/{p...}", UseMiddleware( + []Middleware{ Logged }, ctx, + func(ctx *routes.RouterContext, w http.ResponseWriter, r *http.Request) { + if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { + ctx.ReportForbidden("", w, r) + return + } + rfn := r.PathValue("repoName") + if !model.ValidRepositoryName(rfn) { + ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) + return + } + _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) + if err == routes.ErrNotFound { + ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) + return + } + if err != nil { + ctx.ReportInternalError(err.Error(), w, r) + return + } + if repo.Type != model.REPO_TYPE_GIT { + ctx.ReportNormalError("The repository you have requested isn't a Git repository.", w, r) + return + } + isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC + isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC + isRepoArchived := repo.Status == model.REPO_ARCHIVED + if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { + w.WriteHeader(404) + w.Write([]byte("404 Not Found")) + return + } + // see docs/http-clone.org. + if (r.URL.Query().Has("service")) { + switch r.URL.Query().Get("service") { + case "git-upload-pack": + cmd := exec.Command("git", "upload-pack", repo.LocalPath, "--http-backend-info-refs") + cmd.Dir = repo.LocalPath + protocol := r.Header.Get("Git-Protocol") + if protocol == "" { protocol = "version=2" } + cmd.Env = append(cmd.Env, fmt.Sprintf("GIT_PROTOCOL=%s", protocol)) + stdout := new(bytes.Buffer) + cmd.Stdout = stdout + err := cmd.Run() + if err != nil { + w.WriteHeader(500) + printGitError(w, err.Error()) + return + } + w.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") + w.Header().Set("Cache-Control", "no-cache, max-age=0, must-revalidate") + w.WriteHeader(200) + fmt.Fprint(w, "001e# service=git-upload-pack\n") + fmt.Fprint(w, "0000") + w.Write(stdout.Bytes()) + default: + w.WriteHeader(403) + printGitError(w, "Not supported service.") } - w.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") - w.Header().Set("Cache-Control", "no-cache, max-age=0, must-revalidate") - w.WriteHeader(200) - fmt.Fprint(w, "001e# service=git-upload-pack\n") - fmt.Fprint(w, "0000") - w.Write(stdout.Bytes()) - default: + return + } + // v1-dumb + rr := repo.Repository.(*gitlib.LocalGitRepository) + p := path.Join(rr.GitDirectoryPath, "info", r.PathValue("p")) + s, err := os.ReadFile(p) + if err != nil { + ctx.ReportInternalError("Fail to read info/refs", w, r) + return + } + w.Write(s) + })) + http.HandleFunc("POST /repo/{repoName}/git-upload-pack", UseMiddleware( + []Middleware{ Logged }, ctx, + func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { + if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { w.WriteHeader(403) - printGitError(w, "Not supported service.") - } - return - } - // v1-dumb - rr := repo.Repository.(*gitlib.LocalGitRepository) - p := path.Join(rr.GitDirectoryPath, "info", r.PathValue("p")) - s, err := os.ReadFile(p) - if err != nil { - ctx.ReportInternalError("Fail to read info/refs", w, r) - return - } - w.Write(s) - })) - http.HandleFunc("POST /repo/{repoName}/git-upload-pack", WithLog(func(w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { - w.WriteHeader(403) - w.Write([]byte("Service not available right now.")) - return - } - rfn := r.PathValue("repoName") - if !model.ValidRepositoryName(rfn) { - w.WriteHeader(404) - w.Write([]byte("Repository not found.")) - return - } - _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) - if err == routes.ErrNotFound { - w.WriteHeader(404) - w.Write([]byte("Repository not found.")) - return - } - if err != nil { - ctx.ReportInternalError(err.Error(), w, r) - return - } - if repo.Type != model.REPO_TYPE_GIT { - w.WriteHeader(403) - w.Write([]byte("Repository not Git.")) - return - } - isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC - isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC - isRepoArchived := repo.Status == model.REPO_ARCHIVED - if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { - w.WriteHeader(404) - w.Write([]byte("404 Not Found")) - return - } - w.Header().Set("Content-Type", "application/x-git-upload-pack-response") - w.Header().Set("Cache-Control", "no-cache, max-age=0, must-revalidate") - w.WriteHeader(200) - cmd := exec.Command("git", "upload-pack", repo.LocalPath, "--stateless-rpc") - cmd.Stdin = r.Body - protocol := r.Header.Get("Git-Protocol") - if protocol == "" { protocol = "version=2" } - cmd.Env = append(cmd.Env, fmt.Sprintf("GIT_PROTOCOL=%s", protocol)) - buf := new(bytes.Buffer) - cmd.Stdout = buf - cmd.Run() - io.Copy(w, buf) - })) - http.HandleFunc("GET /repo/{repoName}/HEAD", WithLog(func(w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { - ctx.ReportForbidden("", w, r) - return - } - rfn := r.PathValue("repoName") - if !model.ValidRepositoryName(rfn) { - ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) - return - } - _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) - if err == routes.ErrNotFound { - ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) - return - } - if err != nil { - ctx.ReportInternalError(err.Error(), w, r) - return - } - if repo.Type != model.REPO_TYPE_GIT { - ctx.ReportNormalError("The repository you have requested isn't a Git repository.", w, r) - return - } - isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC - isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC - isRepoArchived := repo.Status == model.REPO_ARCHIVED - if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { - w.WriteHeader(404) - w.Write([]byte("404 Not Found")) - return - } - rr := repo.Repository.(*gitlib.LocalGitRepository) - p := path.Join(rr.GitDirectoryPath, "HEAD") - s, err := os.ReadFile(p) - if err != nil { - ctx.ReportInternalError("Fail to read info/refs", w, r) - return - } - w.Write(s) - })) - http.HandleFunc("GET /repo/{repoName}/objects/{obj...}", WithLog(func(w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { - ctx.ReportForbidden("", w, r) - return - } - rfn := r.PathValue("repoName") - if !model.ValidRepositoryName(rfn) { - ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) - return - } - _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) - if err == routes.ErrNotFound { - ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) - return - } - if err != nil { - ctx.ReportInternalError(err.Error(), w, r) - return - } - if repo.Type != model.REPO_TYPE_GIT { - ctx.ReportNormalError("The repository you have requested isn't a Git repository.", w, r) - return - } - isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC - isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC - isRepoArchived := repo.Status == model.REPO_ARCHIVED - if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { - w.WriteHeader(404) - w.Write([]byte("404 Not Found")) - return - } - obj := r.PathValue("obj") - rr := repo.Repository.(*gitlib.LocalGitRepository) - p := path.Join(rr.GitDirectoryPath, "objects", obj) - s, err := os.ReadFile(p) - if os.IsNotExist(err) { - ctx.ReportNotFound(rfn, "object", ctx.Config.DepotName, w, r) - return - } - if err != nil { - ctx.ReportInternalError("Fail to read info/refs", w, r) - return - } - w.Write(s) - })) + w.Write([]byte("Service not available right now.")) + return + } + rfn := r.PathValue("repoName") + if !model.ValidRepositoryName(rfn) { + w.WriteHeader(404) + w.Write([]byte("Repository not found.")) + return + } + _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) + if err == routes.ErrNotFound { + w.WriteHeader(404) + w.Write([]byte("Repository not found.")) + return + } + if err != nil { + ctx.ReportInternalError(err.Error(), w, r) + return + } + if repo.Type != model.REPO_TYPE_GIT { + w.WriteHeader(403) + w.Write([]byte("Repository not Git.")) + return + } + isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC + isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC + isRepoArchived := repo.Status == model.REPO_ARCHIVED + if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { + w.WriteHeader(404) + w.Write([]byte("404 Not Found")) + return + } + w.Header().Set("Content-Type", "application/x-git-upload-pack-response") + w.Header().Set("Cache-Control", "no-cache, max-age=0, must-revalidate") + w.WriteHeader(200) + cmd := exec.Command("git", "upload-pack", repo.LocalPath, "--stateless-rpc") + cmd.Stdin = r.Body + protocol := r.Header.Get("Git-Protocol") + if protocol == "" { protocol = "version=2" } + cmd.Env = append(cmd.Env, fmt.Sprintf("GIT_PROTOCOL=%s", protocol)) + buf := new(bytes.Buffer) + cmd.Stdout = buf + cmd.Run() + io.Copy(w, buf) + })) + http.HandleFunc("GET /repo/{repoName}/HEAD", UseMiddleware( + []Middleware{ Logged }, ctx, + func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { + if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { + ctx.ReportForbidden("", w, r) + return + } + rfn := r.PathValue("repoName") + if !model.ValidRepositoryName(rfn) { + ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) + return + } + _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) + if err == routes.ErrNotFound { + ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) + return + } + if err != nil { + ctx.ReportInternalError(err.Error(), w, r) + return + } + if repo.Type != model.REPO_TYPE_GIT { + ctx.ReportNormalError("The repository you have requested isn't a Git repository.", w, r) + return + } + isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC + isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC + isRepoArchived := repo.Status == model.REPO_ARCHIVED + if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { + w.WriteHeader(404) + w.Write([]byte("404 Not Found")) + return + } + rr := repo.Repository.(*gitlib.LocalGitRepository) + p := path.Join(rr.GitDirectoryPath, "HEAD") + s, err := os.ReadFile(p) + if err != nil { + ctx.ReportInternalError("Fail to read info/refs", w, r) + return + } + w.Write(s) + })) + http.HandleFunc("GET /repo/{repoName}/objects/{obj...}", UseMiddleware( + []Middleware{ Logged }, ctx, + func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { + if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { + ctx.ReportForbidden("", w, r) + return + } + rfn := r.PathValue("repoName") + if !model.ValidRepositoryName(rfn) { + ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) + return + } + _, _, ns, repo, err := ctx.ResolveRepositoryFullName(rfn) + if err == routes.ErrNotFound { + ctx.ReportNotFound(rfn, "Repository", "Depot", w, r) + return + } + if err != nil { + ctx.ReportInternalError(err.Error(), w, r) + return + } + if repo.Type != model.REPO_TYPE_GIT { + ctx.ReportNormalError("The repository you have requested isn't a Git repository.", w, r) + return + } + isNamespacePublic := ns.Status == model.NAMESPACE_NORMAL_PUBLIC + isRepoPublic := repo.Status == model.REPO_NORMAL_PUBLIC + isRepoArchived := repo.Status == model.REPO_ARCHIVED + if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { + w.WriteHeader(404) + w.Write([]byte("404 Not Found")) + return + } + obj := r.PathValue("obj") + rr := repo.Repository.(*gitlib.LocalGitRepository) + p := path.Join(rr.GitDirectoryPath, "objects", obj) + s, err := os.ReadFile(p) + if os.IsNotExist(err) { + ctx.ReportNotFound(rfn, "object", ctx.Config.DepotName, w, r) + return + } + if err != nil { + ctx.ReportInternalError("Fail to read info/refs", w, r) + return + } + w.Write(s) + })) } diff --git a/templates/_footer.template.html b/templates/_footer.template.html index c16041d..50d9bae 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file From 9fd87c90e76acf510afc994a5a7d6501db5fa0d9 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Sat, 27 Dec 2025 12:44:09 +0000 Subject: [PATCH 08/19] fix: fix readme ui for plaintext --- COUNT | 2 +- routes/controller/repository.go | 2 +- templates/_footer.template.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/COUNT b/COUNT index 6504c90..c596bff 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,60 \ No newline at end of file +v0.1.6-alpha,61 \ No newline at end of file diff --git a/routes/controller/repository.go b/routes/controller/repository.go index 7070bac..5c30d55 100644 --- a/routes/controller/repository.go +++ b/routes/controller/repository.go @@ -194,7 +194,7 @@ func bindRepositoryController(ctx *RouterContext) { } default: readmeString = bluemonday.UGCPolicy().Sanitize(readmeString) - readmeString = fmt.Sprintf("
%s
", readmeString) + readmeString = fmt.Sprintf("
%s
", readmeString) } // resolve branch comparison info... if isFork { diff --git a/templates/_footer.template.html b/templates/_footer.template.html index 50d9bae..f6cc224 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file From b3961fd7872745e15f3ff5e146404073f9197e7e Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Sat, 27 Dec 2025 14:34:27 +0000 Subject: [PATCH 09/19] feat: login/logout callback (js) unfortunately this is currently only available for js-enabled browsers. --- COUNT | 2 +- routes/controller/login.go | 6 +++++- routes/controller/logout.go | 5 ++++- templates/_footer.template.html | 2 +- templates/_header-nav.template.html | 19 +++++++++++++++++-- templates/login.model.go | 1 + templates/login.template.html | 1 + 7 files changed, 30 insertions(+), 6 deletions(-) diff --git a/COUNT b/COUNT index c596bff..c132441 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,61 \ No newline at end of file +v0.1.6-alpha,70 \ No newline at end of file diff --git a/routes/controller/login.go b/routes/controller/login.go index 75a9995..5e6a77d 100644 --- a/routes/controller/login.go +++ b/routes/controller/login.go @@ -3,6 +3,7 @@ package controller import ( "fmt" "net/http" + "strings" "time" "github.com/bctnry/aegis/pkg/aegis" @@ -26,6 +27,7 @@ func bindLoginController(ctx *RouterContext) { LogTemplateError(ctx.LoadTemplate("login").Execute(w, templates.LoginTemplateModel{ Config: ctx.Config, LoginInfo: rc.LoginInfo, + Callback: r.URL.Query().Get("callback"), })) }, )) @@ -162,7 +164,9 @@ If this isn't you, we advise you to change your password on %s and other platfor Secure: true, SameSite: http.SameSiteDefaultMode, }).String()) - FoundAt(w, "/") + callbackURL := strings.TrimSpace(r.Form.Get("login-callback")) + if callbackURL == "" { callbackURL = "/" } + FoundAt(w, callbackURL) }, )) diff --git a/routes/controller/logout.go b/routes/controller/logout.go index 20def76..6003fc8 100644 --- a/routes/controller/logout.go +++ b/routes/controller/logout.go @@ -2,6 +2,7 @@ package controller import ( "net/http" + "strings" "github.com/bctnry/aegis/pkg/aegis" . "github.com/bctnry/aegis/routes" @@ -49,7 +50,9 @@ func bindLogoutController(ctx *RouterContext) { Secure: true, SameSite: http.SameSiteDefaultMode, }).String()) - FoundAt(w, "/") + callbackURL := strings.TrimSpace(r.URL.Query().Get("callback")) + if callbackURL == "" { callbackURL = "/" } + FoundAt(w, callbackURL) }, )) } diff --git a/templates/_footer.template.html b/templates/_footer.template.html index f6cc224..54e20b3 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/_header-nav.template.html b/templates/_header-nav.template.html index dfe17c5..c839fe2 100644 --- a/templates/_header-nav.template.html +++ b/templates/_header-nav.template.html @@ -18,9 +18,9 @@ {{.LoginInfo.UserName}} {{if .LoginInfo.IsAdmin}}ADMIN{{end}} SETTING - LOGOUT + LOGOUT {{else}} - LOGIN + LOGIN {{if .Config.AllowRegistration}} | SIGN UP {{end}} @@ -35,4 +35,19 @@
{{end}} + + {{end}} diff --git a/templates/login.model.go b/templates/login.model.go index 19d2971..1f11ba4 100644 --- a/templates/login.model.go +++ b/templates/login.model.go @@ -8,5 +8,6 @@ type LoginTemplateModel struct { Config *aegis.AegisConfig ErrorMsg string LoginInfo *LoginInfoModel + Callback string } diff --git a/templates/login.template.html b/templates/login.template.html index dbcd8d9..9b1b893 100644 --- a/templates/login.template.html +++ b/templates/login.template.html @@ -24,6 +24,7 @@

Login

Login
+
From f4510996ff15b4a67997615de580aee6117bb487 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Sat, 27 Dec 2025 22:58:48 +0000 Subject: [PATCH 10/19] refactor: refactor --- COUNT | 2 +- pkg/aegis/config.go | 11 ++++++----- pkg/aegis/db/postgres/query.go | 4 ++-- pkg/aegis/db/sqlite/query.go | 10 +++++----- pkg/aegis/model/localrepo.go | 2 +- pkg/aegis/model/namespace.go | 2 +- pkg/gitlib/repository.go | 14 +------------- routes/controller/branch.go | 6 +++--- routes/controller/commit.go | 6 +++--- routes/controller/tag.go | 9 +++++---- routes/controller/tree.go | 7 ++++--- static/style-login.css | 2 +- static/style-registration.css | 7 ++++++- templates/_footer.template.html | 2 +- templates/registration.template.html | 2 +- templates/retrieveCommentOnCode.func.go | 2 +- 16 files changed, 42 insertions(+), 46 deletions(-) diff --git a/COUNT b/COUNT index c132441..bbe4a98 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,70 \ No newline at end of file +v0.1.6-alpha,92 \ No newline at end of file diff --git a/pkg/aegis/config.go b/pkg/aegis/config.go index f077270..8071927 100644 --- a/pkg/aegis/config.go +++ b/pkg/aegis/config.go @@ -151,6 +151,7 @@ type AegisConfig struct { // currently it's just a foreground color & a background color but there // could be more in the future. Theme AegisThemeConfig `json:"theme"` + } const ( @@ -589,10 +590,10 @@ func (cfg *AegisConfig) GetAllRepositoryPlain() ([]*model.Repository, error) { continue } } - k := gitlib.NewLocalGitRepository("", repoName, p) + k := gitlib.NewLocalGitRepository(p) res = append(res, &model.Repository{ - Namespace: k.Namespace, - Name: k.Name, + Namespace: "", + Name: repoName, Description: k.Description, AccessControlList: nil, Status: model.REPO_NORMAL_PUBLIC, @@ -629,11 +630,11 @@ func (cfg *AegisConfig) GetAllRepositoryByNamespacePlain(ns string) (map[string] continue } } - k := gitlib.NewLocalGitRepository("", repoName, p) + k := gitlib.NewLocalGitRepository(p) res[repoName] = &model.Repository{ Type: model.GuessRepositoryType(p), Namespace: ns, - Name: k.Name, + Name: repoName, Description: k.Description, AccessControlList: nil, Status: model.REPO_NORMAL_PUBLIC, diff --git a/pkg/aegis/db/postgres/query.go b/pkg/aegis/db/postgres/query.go index 8662f3a..c7fed68 100644 --- a/pkg/aegis/db/postgres/query.go +++ b/pkg/aegis/db/postgres/query.go @@ -2251,7 +2251,7 @@ WHERE pull_request_absid = $1 if err != nil { return nil, err } defer tx.Rollback(ctx) p := path.Join(dbif.config.GitRoot, receiverNamespace, receiverName) - lgr := gitlib.NewLocalGitRepository(receiverNamespace, receiverName, p) + lgr := gitlib.NewLocalGitRepository(p) remoteName := fmt.Sprintf("%s/%s", providerNamespace, providerName) mr, err := lgr.CheckBranchMergeConflict(receiverBranch, remoteName, providerBranch) if err != nil { return nil, err } @@ -3035,7 +3035,7 @@ ORDER BY repo_name ASC, repo_namespace ASC LIMIT $5 OFFSET $6 Description: desc, AccessControlList: a, Status: model.AegisRepositoryStatus(status), - Repository: gitlib.NewLocalGitRepository(ns, name, p), + Repository: gitlib.NewLocalGitRepository(p), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, RepoLabelList: tags, diff --git a/pkg/aegis/db/sqlite/query.go b/pkg/aegis/db/sqlite/query.go index 60e5140..0251da0 100644 --- a/pkg/aegis/db/sqlite/query.go +++ b/pkg/aegis/db/sqlite/query.go @@ -450,7 +450,7 @@ WHERE repo_namespace = ? AND repo_name = ? tags = strings.Split(labelList[1:len(labelList)-1], "}{") } p := path.Join(dbif.config.GitRoot, nsName, repoName) - res, err := model.NewRepository(nsName, repoName, gitlib.NewLocalGitRepository(nsName, repoName, p)) + res, err := model.NewRepository(nsName, repoName, gitlib.NewLocalGitRepository(p)) res.AbsId = rowid res.Type = repoType res.Owner = owner @@ -676,7 +676,7 @@ AND (repo_status = 1 OR repo_status = 4) Description: desc, AccessControlList: a, Status: model.AegisRepositoryStatus(status), - Repository: gitlib.NewLocalGitRepository(ns, name, p), + Repository: gitlib.NewLocalGitRepository(p), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, RepoLabelList: tags, @@ -722,7 +722,7 @@ WHERE repo_namespace = ? Description: desc, AccessControlList: a, Status: model.AegisRepositoryStatus(status), - Repository: gitlib.NewLocalGitRepository(ns, name, p), + Repository: gitlib.NewLocalGitRepository(p), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, RepoLabelList: tags, @@ -2646,7 +2646,7 @@ WHERE rowid = ? if err != nil { return nil, err } defer tx.Rollback() p := path.Join(dbif.config.GitRoot, receiverNamespace, receiverName) - lgr := gitlib.NewLocalGitRepository(receiverNamespace, receiverName, p) + lgr := gitlib.NewLocalGitRepository(p) remoteName := fmt.Sprintf("%s/%s", providerNamespace, providerName) mr, err := lgr.CheckBranchMergeConflict(receiverBranch, remoteName, providerBranch) if err != nil { return nil, err } @@ -3494,7 +3494,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Description: desc, AccessControlList: a, Status: model.AegisRepositoryStatus(status), - Repository: gitlib.NewLocalGitRepository(ns, name, p), + Repository: gitlib.NewLocalGitRepository(p), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, RepoLabelList: tags, diff --git a/pkg/aegis/model/localrepo.go b/pkg/aegis/model/localrepo.go index d72f0ca..69c9a5f 100644 --- a/pkg/aegis/model/localrepo.go +++ b/pkg/aegis/model/localrepo.go @@ -26,7 +26,7 @@ func GetAegisType(x LocalRepository) uint8 { func CreateLocalRepository(repoType uint8, namespace string, name string, dirPath string) (LocalRepository, error) { switch repoType { case REPO_TYPE_GIT: - return gitlib.NewLocalGitRepository(namespace, name, dirPath), nil + return gitlib.NewLocalGitRepository(dirPath), nil default: return nil, ErrNotSupported } diff --git a/pkg/aegis/model/namespace.go b/pkg/aegis/model/namespace.go index 49ef1b2..6aa6e63 100644 --- a/pkg/aegis/model/namespace.go +++ b/pkg/aegis/model/namespace.go @@ -79,7 +79,7 @@ func NewNamespace(name string, p string) (*Namespace, error) { continue } } - r, err := NewRepository(name, repoName, gitlib.NewLocalGitRepository(name, repoName, repoPath)) + r, err := NewRepository(name, repoName, gitlib.NewLocalGitRepository(repoPath)) if err != nil { return nil, err } repoMap[repoName] = r } diff --git a/pkg/gitlib/repository.go b/pkg/gitlib/repository.go index 2a5b0e7..814a99e 100644 --- a/pkg/gitlib/repository.go +++ b/pkg/gitlib/repository.go @@ -16,8 +16,6 @@ import ( ) type LocalGitRepository struct { - Namespace string - Name string GitDirectoryPath string Description string PackIndex map[string]*PackIndex @@ -33,18 +31,8 @@ func (gr LocalGitRepository) IsSHA256() bool { return gr.isSHA256 } -func (gr LocalGitRepository) FullName() string { - if len(gr.Namespace) > 0 { - return fmt.Sprintf("%s:%s", gr.Namespace, gr.Name) - } else { - return gr.Name - } -} - -func NewLocalGitRepository(namespace string, name string, p string) *LocalGitRepository { +func NewLocalGitRepository(/* namespace string, name string,*/ p string) *LocalGitRepository { res := LocalGitRepository{ - Namespace: namespace, - Name: name, GitDirectoryPath: p, PackIndex: nil, Hooks: nil, diff --git a/routes/controller/branch.go b/routes/controller/branch.go index a351e1d..d5a3459 100644 --- a/routes/controller/branch.go +++ b/routes/controller/branch.go @@ -17,12 +17,12 @@ import ( "github.com/bctnry/aegis/templates" ) -func handleBranchSnapshotRequest(repo *gitlib.LocalGitRepository, branchName string, obj gitlib.GitObject, w http.ResponseWriter) { +func handleBranchSnapshotRequest(repo *model.Repository, branchName string, obj gitlib.GitObject, w http.ResponseWriter) { filename := fmt.Sprintf( "%s-%s-branch-%s", repo.Namespace, repo.Name, branchName, ) - responseWithTreeZip(repo, obj, filename, w) + responseWithTreeZip(repo.Repository.(*gitlib.LocalGitRepository), obj, filename, w) } func bindBranchController(ctx *RouterContext) { @@ -135,7 +135,7 @@ func bindBranchController(ctx *RouterContext) { w.Write((target.(*gitlib.BlobObject)).Data) return } else { - handleBranchSnapshotRequest(rr, branchName, target, w) + handleBranchSnapshotRequest(repo, branchName, target, w) return } } diff --git a/routes/controller/commit.go b/routes/controller/commit.go index 9c656b6..06985f4 100644 --- a/routes/controller/commit.go +++ b/routes/controller/commit.go @@ -15,12 +15,12 @@ import ( "github.com/bctnry/aegis/templates" ) -func handleCommitSnapshotRequest(repo *gitlib.LocalGitRepository, commitId string, obj gitlib.GitObject, w http.ResponseWriter) { +func handleCommitSnapshotRequest(repo *model.Repository, commitId string, obj gitlib.GitObject, w http.ResponseWriter) { filename := fmt.Sprintf( "%s-%s-commit-%s", repo.Namespace, repo.Name, commitId, ) - responseWithTreeZip(repo, obj, filename, w) + responseWithTreeZip(repo.Repository.(*gitlib.LocalGitRepository), obj, filename, w) } func bindCommitController(ctx *RouterContext) { @@ -118,7 +118,7 @@ func bindCommitController(ctx *RouterContext) { w.Write((target.(*gitlib.BlobObject)).Data) return } else { - handleCommitSnapshotRequest(rr, commitId, target, w) + handleCommitSnapshotRequest(repo, commitId, target, w) return } } diff --git a/routes/controller/tag.go b/routes/controller/tag.go index be60b15..0d4ad65 100644 --- a/routes/controller/tag.go +++ b/routes/controller/tag.go @@ -15,12 +15,13 @@ import ( "github.com/bctnry/aegis/templates" ) -func handleTagSnapshotRequest(repo *gitlib.LocalGitRepository, branchName string, obj gitlib.GitObject, w http.ResponseWriter) error { +func handleTagSnapshotRequest(repo *model.Repository, branchName string, obj gitlib.GitObject, w http.ResponseWriter) error { // would resolve tags that point to tags. subj := obj var err error = nil + rr := repo.Repository.(*gitlib.LocalGitRepository) for subj.Type() == gitlib.TAG { - subj, err = repo.ReadObject((subj.(*gitlib.TagObject)).TaggedObjId) + subj, err = rr.ReadObject((subj.(*gitlib.TagObject)).TaggedObjId) if err != nil { return err } } filename := fmt.Sprintf( @@ -28,7 +29,7 @@ func handleTagSnapshotRequest(repo *gitlib.LocalGitRepository, branchName string repo.Namespace, repo.Name, branchName, ) if subj.Type() == gitlib.TREE { - return responseWithTreeZip(repo, obj, filename, w) + return responseWithTreeZip(rr, obj, filename, w) } else { w.Write(subj.RawData()) return nil @@ -109,7 +110,7 @@ func bindTagController(ctx *RouterContext) { } if r.URL.Query().Has("snapshot") { - handleTagSnapshotRequest(rr, tagName, tobj, w) + handleTagSnapshotRequest(repo, tagName, tobj, w) return } diff --git a/routes/controller/tree.go b/routes/controller/tree.go index 399eaa0..132187b 100644 --- a/routes/controller/tree.go +++ b/routes/controller/tree.go @@ -12,12 +12,13 @@ import ( "github.com/bctnry/aegis/templates" ) -func handleTreeSnapshotRequest(repo *gitlib.LocalGitRepository, treeId string, obj gitlib.GitObject, w http.ResponseWriter) { +func handleTreeSnapshotRequest(repo *model.Repository, treeId string, obj gitlib.GitObject, w http.ResponseWriter) { + rr := repo.Repository.(*gitlib.LocalGitRepository) filename := fmt.Sprintf( "%s-%s-tree-%s", repo.Namespace, repo.Name, treeId, ) - responseWithTreeZip(repo, obj, filename, w) + responseWithTreeZip(rr, obj, filename, w) } func bindTreeHandler(ctx *RouterContext) { @@ -94,7 +95,7 @@ func bindTreeHandler(ctx *RouterContext) { isSnapshotRequest := r.URL.Query().Has("snapshot") if isSnapshotRequest { - handleTreeSnapshotRequest(rr, treeId, target, w) + handleTreeSnapshotRequest(repo, treeId, target, w) return } diff --git a/static/style-login.css b/static/style-login.css index 2f3b0e4..aa2f907 100644 --- a/static/style-login.css +++ b/static/style-login.css @@ -1,6 +1,6 @@ #login-form { - width: 50%; + width: 75%; margin-top: 2rem; margin-bottom: 2rem; } diff --git a/static/style-registration.css b/static/style-registration.css index a977203..dc65524 100644 --- a/static/style-registration.css +++ b/static/style-registration.css @@ -1,12 +1,17 @@ #reg-form { - width: 50%; + width: 75%; margin-top: 2rem; margin-bottom: 2rem; } +#ta-reason { + resize: vertical; +} + @media (max-width: 600px) { #reg-form { width: 100%; } } + diff --git a/templates/_footer.template.html b/templates/_footer.template.html index 54e20b3..cb7802e 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/registration.template.html b/templates/registration.template.html index c8dae29..7210332 100644 --- a/templates/registration.template.html +++ b/templates/registration.template.html @@ -41,7 +41,7 @@

Registration

{{if .Config.ManualApproval}}
- + {{end}} diff --git a/templates/retrieveCommentOnCode.func.go b/templates/retrieveCommentOnCode.func.go index 1f1efa0..ab0be69 100644 --- a/templates/retrieveCommentOnCode.func.go +++ b/templates/retrieveCommentOnCode.func.go @@ -11,7 +11,7 @@ func(cfg *aegis.AegisConfig, s string) *model.PullRequestCommentOnCode { var r *model.PullRequestCommentOnCode json.Unmarshal([]byte(s), &r) p := path.Join(cfg.GitRoot, r.RepoNamespace, r.RepoName) - localRepo := gitlib.NewLocalGitRepository(r.RepoNamespace, r.RepoName, p) + localRepo := gitlib.NewLocalGitRepository(p) gobj, err := localRepo.ReadObject(r.CommitId) if err != nil { log.Fatal(err.Error()) } if gobj.Type() != gitlib.COMMIT { From edf5fddc9aa8c0e790764b0df8762f8104dd13e1 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Mon, 29 Dec 2025 21:45:43 +0000 Subject: [PATCH 11/19] fix: callback path arbitrary url --- pkg/gitlib/repository.go | 2 +- routes/controller/aux.go | 6 ++++++ routes/controller/login.go | 4 +++- routes/controller/logout.go | 4 +++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/gitlib/repository.go b/pkg/gitlib/repository.go index 814a99e..8ee1e57 100644 --- a/pkg/gitlib/repository.go +++ b/pkg/gitlib/repository.go @@ -31,7 +31,7 @@ func (gr LocalGitRepository) IsSHA256() bool { return gr.isSHA256 } -func NewLocalGitRepository(/* namespace string, name string,*/ p string) *LocalGitRepository { +func NewLocalGitRepository(p string) *LocalGitRepository { res := LocalGitRepository{ GitDirectoryPath: p, PackIndex: nil, diff --git a/routes/controller/aux.go b/routes/controller/aux.go index cd37acb..19910db 100644 --- a/routes/controller/aux.go +++ b/routes/controller/aux.go @@ -246,3 +246,9 @@ func newConfirmCode() string { return string(res) } +func getQueryPath(s string) (string, error) { + u, err := url.Parse(s) + if err != nil { return "", err } + return fmt.Sprintf("%s?%s", u.Path, u.Query().Encode()), nil +} + diff --git a/routes/controller/login.go b/routes/controller/login.go index 5e6a77d..c911a1a 100644 --- a/routes/controller/login.go +++ b/routes/controller/login.go @@ -166,7 +166,9 @@ If this isn't you, we advise you to change your password on %s and other platfor }).String()) callbackURL := strings.TrimSpace(r.Form.Get("login-callback")) if callbackURL == "" { callbackURL = "/" } - FoundAt(w, callbackURL) + target, err := getQueryPath(callbackURL) + if err != nil { target = "/" } + FoundAt(w, target) }, )) diff --git a/routes/controller/logout.go b/routes/controller/logout.go index 6003fc8..4c80754 100644 --- a/routes/controller/logout.go +++ b/routes/controller/logout.go @@ -52,7 +52,9 @@ func bindLogoutController(ctx *RouterContext) { }).String()) callbackURL := strings.TrimSpace(r.URL.Query().Get("callback")) if callbackURL == "" { callbackURL = "/" } - FoundAt(w, callbackURL) + target, err := getQueryPath(callbackURL) + if err != nil { target = "/" } + FoundAt(w, target) }, )) } From 8d150d6937fba9a96d3ff980695c388379164927 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Mon, 29 Dec 2025 22:52:00 +0000 Subject: [PATCH 12/19] fix: fix --- COUNT | 2 +- routes/controller/aux.go | 4 +++- templates/_footer.template.html | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/COUNT b/COUNT index bbe4a98..5cb1dcc 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,92 \ No newline at end of file +v0.1.6-alpha,93 \ No newline at end of file diff --git a/routes/controller/aux.go b/routes/controller/aux.go index 19910db..8bb9f15 100644 --- a/routes/controller/aux.go +++ b/routes/controller/aux.go @@ -249,6 +249,8 @@ func newConfirmCode() string { func getQueryPath(s string) (string, error) { u, err := url.Parse(s) if err != nil { return "", err } - return fmt.Sprintf("%s?%s", u.Path, u.Query().Encode()), nil + return fmt.Sprintf("%s?%s", + url.QueryEscape(u.Path), + url.QueryEscape(u.Query().Encode())), nil } diff --git a/templates/_footer.template.html b/templates/_footer.template.html index cb7802e..a149e88 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file From e12e2d7c6e10eaa2fc75e5abd7f09a5aeb4fd517 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Mon, 29 Dec 2025 23:04:24 +0000 Subject: [PATCH 13/19] fix: finally --- routes/controller/aux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/controller/aux.go b/routes/controller/aux.go index 8bb9f15..5718fe0 100644 --- a/routes/controller/aux.go +++ b/routes/controller/aux.go @@ -249,8 +249,8 @@ func newConfirmCode() string { func getQueryPath(s string) (string, error) { u, err := url.Parse(s) if err != nil { return "", err } - return fmt.Sprintf("%s?%s", - url.QueryEscape(u.Path), + return fmt.Sprintf("/%s?%s", + url.QueryEscape(u.Path[1:]), url.QueryEscape(u.Query().Encode())), nil } From 94cda020afa835f99e52b047fc4070fad8430111 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Tue, 30 Dec 2025 23:17:44 +0000 Subject: [PATCH 14/19] feat: switches for turning on/off git http clone protocols --- COUNT | 2 +- cmd/aegis/webinstaller.go | 5 +-- pkg/aegis/config.go | 19 +++++++++++ routes/controller/admin/site-config.go | 17 ++++++++-- routes/controller/http-clone.go | 21 ++++++++++-- templates/_comparison-notice.template.html | 8 +++-- templates/_footer.template.html | 2 +- templates/admin/site-config.template.html | 37 ++++++++++++++++----- templates/shouldShowSynchronizeLink.func.go | 1 + templates/webinstaller/step1.template.html | 6 ++-- templates/webinstaller/step6.template.html | 19 +++++++++-- 11 files changed, 113 insertions(+), 24 deletions(-) diff --git a/COUNT b/COUNT index 5cb1dcc..d66078b 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,93 \ No newline at end of file +v0.1.6-alpha,104 \ No newline at end of file diff --git a/cmd/aegis/webinstaller.go b/cmd/aegis/webinstaller.go index 87fe5f2..28ed232 100644 --- a/cmd/aegis/webinstaller.go +++ b/cmd/aegis/webinstaller.go @@ -43,7 +43,7 @@ type WebInstallerRoutingContext struct { // step 3 - session config // step 4 - mailer config // step 5 - receipt system config - // step 6 - git root & git user + // step 6 - git-related config // step 7 - ignored namespaces & repositories // step 8 - web front setup: // depot name @@ -244,7 +244,6 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { })) http.HandleFunc("GET /step6", withLog(func(w http.ResponseWriter, r *http.Request) { - fmt.Println(ctx.Config.GitUser, ctx.Config.GitRoot) logTemplateError(ctx.loadTemplate("webinstaller/step6").Execute(w, &templates.WebInstallerTemplateModel{ Config: ctx.Config, ConfirmStageReached: ctx.ConfirmStageReached, @@ -259,6 +258,8 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { ctx.Config.GitRoot = strings.TrimSpace(r.Form.Get("git-root")) ctx.Config.GitUser = strings.TrimSpace(r.Form.Get("git-user")) ctx.Config.SnippetRoot = strings.TrimSpace(r.Form.Get("snippet-root")) + ctx.Config.GitConfig.HTTPCloneProtocol.V1Dumb = len(strings.TrimSpace(r.Form.Get("git-http-clone-enable-v1-dumb"))) > 0 + ctx.Config.GitConfig.HTTPCloneProtocol.V2 = len(strings.TrimSpace(r.Form.Get("git-http-clone-enable-v2"))) > 0 next := "" if ctx.Config.IsInPlainMode() { next = "/step7" diff --git a/pkg/aegis/config.go b/pkg/aegis/config.go index 8071927..e9f652f 100644 --- a/pkg/aegis/config.go +++ b/pkg/aegis/config.go @@ -65,6 +65,10 @@ type AegisConfig struct { // when set to true, all registration must be screened by the webmaster. ManualApproval bool `json:"requireManualApproval"` + // git-related config. + // NOTE(2025.12.30): we'll gradually move certain config options into here. + GitConfig AegisGitConfig `json:"gitConfig"` + // cosmetic things... // the name of the depot (i.e. the top level of the site) @@ -188,6 +192,15 @@ type AegisDatabaseConfig struct { TablePrefix string `json:"tablePrefix"` } +type AegisGitHTTPTransferProtocolDescriptor struct { + // true if enabled. + V1Dumb bool `json:"v1dumb"` + V2 bool `json:"v2"` +} +type AegisGitConfig struct { + HTTPCloneProtocol AegisGitHTTPTransferProtocolDescriptor `json:"httpCloneProtocol"` +} + type AegisSessionConfig struct { // session type. currently only support: // + "sqlite" @@ -364,6 +377,12 @@ func CreateConfigFile(p string) error { IgnoreRepository: nil, GlobalVisibility: "public", FullAccessUser: []string{"admin"}, + GitConfig: AegisGitConfig{ + HTTPCloneProtocol: AegisGitHTTPTransferProtocolDescriptor{ + V1Dumb: true, + V2: true, + }, + }, Database: AegisDatabaseConfig{ Type: "sqlite", Path: "", diff --git a/routes/controller/admin/site-config.go b/routes/controller/admin/site-config.go index 2593d9f..599388b 100644 --- a/routes/controller/admin/site-config.go +++ b/routes/controller/admin/site-config.go @@ -60,8 +60,6 @@ func bindAdminSiteConfigController(ctx *RouterContext) { rc.ReportRedirect("/admin/site-config", 3, "Updated", "Your specifie config has been updated.", w, r) case "basic": rc.Config.DepotName = r.Form.Get("depot-name") - rc.Config.GitRoot = r.Form.Get("root") - rc.Config.GitUser = r.Form.Get("git-user") rc.Config.UseNamespace = false if r.Form.Has("use-namespace") && r.Form.Get("use-namespace") == "on" { rc.Config.UseNamespace = true @@ -89,6 +87,21 @@ func bindAdminSiteConfigController(ctx *RouterContext) { return } rc.ReportRedirect("/admin/site-config", 3, "Updated", "Your specifie config has been updated.", w, r) + case "git": + rc.Config.GitRoot = r.Form.Get("root") + rc.Config.GitUser = r.Form.Get("git-user") + rc.Config.GitConfig.HTTPCloneProtocol.V1Dumb = len(strings.TrimSpace(r.Form.Get("git-http-enable-v1dumb"))) > 0 + rc.Config.GitConfig.HTTPCloneProtocol.V2 = len(strings.TrimSpace(r.Form.Get("git-http-enable-v2"))) > 0 + err := rc.Config.Sync() + if err != nil { + LogTemplateError(rc.LoadTemplate("admin/site-config").Execute(w, &templates.AdminConfigTemplateModel{ + Config: rc.Config, + LoginInfo: rc.LoginInfo, + ErrorMsg: fmt.Sprintf("Error while saving config: %s. Please contact site owner for this...", err.Error()), + })) + return + } + rc.ReportRedirect("/admin/site-config", 3, "Updated", "Your specifie config has been updated.", w, r) case "theme-config": rc.Config.Theme.ForegroundColor = strings.TrimSpace(r.Form.Get("foreground-color")) rc.Config.Theme.BackgroundColor = strings.TrimSpace(r.Form.Get("background-color")) diff --git a/routes/controller/http-clone.go b/routes/controller/http-clone.go index 413b477..a94943e 100644 --- a/routes/controller/http-clone.go +++ b/routes/controller/http-clone.go @@ -33,6 +33,13 @@ func bindHttpCloneController(ctx *RouterContext) { http.HandleFunc("GET /repo/{repoName}/info/{p...}", UseMiddleware( []Middleware{ Logged }, ctx, func(ctx *routes.RouterContext, w http.ResponseWriter, r *http.Request) { + allowV2 := ctx.Config.GitConfig.HTTPCloneProtocol.V2 + allowV1Dumb := ctx.Config.GitConfig.HTTPCloneProtocol.V1Dumb + if !allowV1Dumb && !allowV2 { + w.WriteHeader(403) + fmt.Fprint(w, "HTTP clone not supported on this instance") + return + } if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { ctx.ReportForbidden("", w, r) return @@ -60,11 +67,11 @@ func bindHttpCloneController(ctx *RouterContext) { isRepoArchived := repo.Status == model.REPO_ARCHIVED if !isNamespacePublic || !(isRepoPublic || isRepoArchived) { w.WriteHeader(404) - w.Write([]byte("404 Not Found")) + fmt.Fprint(w, "404 Not Found") return } // see docs/http-clone.org. - if (r.URL.Query().Has("service")) { + if (r.URL.Query().Has("service") && allowV2) { switch r.URL.Query().Get("service") { case "git-upload-pack": cmd := exec.Command("git", "upload-pack", repo.LocalPath, "--http-backend-info-refs") @@ -93,6 +100,11 @@ func bindHttpCloneController(ctx *RouterContext) { return } // v1-dumb + if !allowV1Dumb { + w.WriteHeader(403) + fmt.Fprint(w, "v1-dumb protocl not supported on this instance.") + return + } rr := repo.Repository.(*gitlib.LocalGitRepository) p := path.Join(rr.GitDirectoryPath, "info", r.PathValue("p")) s, err := os.ReadFile(p) @@ -105,6 +117,11 @@ func bindHttpCloneController(ctx *RouterContext) { http.HandleFunc("POST /repo/{repoName}/git-upload-pack", UseMiddleware( []Middleware{ Logged }, ctx, func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { + if !ctx.Config.GitConfig.HTTPCloneProtocol.V2 { + w.WriteHeader(403) + fmt.Fprint(w, "v2 protocl not supported on this instance.") + return + } if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { w.WriteHeader(403) w.Write([]byte("Service not available right now.")) diff --git a/templates/_comparison-notice.template.html b/templates/_comparison-notice.template.html index e83b562..c4ad448 100644 --- a/templates/_comparison-notice.template.html +++ b/templates/_comparison-notice.template.html @@ -1,11 +1,13 @@ {{define "_comparison-notice"}} Fork Notice: - {{if gt (len .BRevList) 0}} + {{if . }} + {{if and .BRevList (gt (len .BRevList)) 0}} This repository is {{len .BRevList}} commits beyond {{if gt (len .ARevList) 0}} and {{len .ARevList}} commits behind {{end}}upstream. - {{else if gt (len .ARevList) 0}} + {{else if and .ARevList (gt (len .ARevList)) 0}} This repository is {{len .ARevList}} commits behind upstream. - {{else if .}} + {{else}} This repository is in sync with upstream. + {{end}} {{else}} This repository seems to be empty. {{end}} diff --git a/templates/_footer.template.html b/templates/_footer.template.html index a149e88..c3c2df3 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/admin/site-config.template.html b/templates/admin/site-config.template.html index f01500a..349ffe7 100644 --- a/templates/admin/site-config.template.html +++ b/templates/admin/site-config.template.html @@ -31,14 +31,6 @@

Admin

- - - - - - - - @@ -62,6 +54,35 @@

Admin

+ +
+ Git Settings +
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
Web Setting diff --git a/templates/shouldShowSynchronizeLink.func.go b/templates/shouldShowSynchronizeLink.func.go index fd7e453..ad0114a 100644 --- a/templates/shouldShowSynchronizeLink.func.go +++ b/templates/shouldShowSynchronizeLink.func.go @@ -6,6 +6,7 @@ import "github.com/bctnry/aegis/pkg/gitlib" func(s *LoginInfoModel, ci *gitlib.BranchComparisonInfo) bool { if !s.LoggedIn { return false } if !s.IsOwner { return false } + if ci == nil { return true } if len(ci.ARevList) > 0 && len(ci.BRevList) <= 0 { return true } return false } diff --git a/templates/webinstaller/step1.template.html b/templates/webinstaller/step1.template.html index e15c1a5..73d0be6 100644 --- a/templates/webinstaller/step1.template.html +++ b/templates/webinstaller/step1.template.html @@ -31,9 +31,9 @@

Step 1

diff --git a/templates/webinstaller/step6.template.html b/templates/webinstaller/step6.template.html index 2c9eac9..9ee0135 100644 --- a/templates/webinstaller/step6.template.html +++ b/templates/webinstaller/step6.template.html @@ -13,7 +13,7 @@

Aegis Web Installer


-

Step 6: Git Root & Git User

+

Step 6: Git-Related Configurations

@@ -41,7 +41,22 @@

Step 6: Git Root & Git User

- + +
+ Git HTTP Clone Protocol +

Configure the supported Git-over-HTTP protocols (see docs/http-clone.org).

+ + + + + + + + + + +
FieldValue
+
From 4b3e550bbc59590d29fa3b8291f04ac0cca3f741 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Thu, 1 Jan 2026 05:26:56 +0000 Subject: [PATCH 15/19] docs: docs for hg --- docs/hg-vs-git.org | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 docs/hg-vs-git.org diff --git a/docs/hg-vs-git.org b/docs/hg-vs-git.org new file mode 100644 index 0000000..b20f662 --- /dev/null +++ b/docs/hg-vs-git.org @@ -0,0 +1,30 @@ +* hg vs. git + +this file is to write down the difference between mercurial and git. + +** commit structure + +for git: + ++ 4 kinds of obejct: commit, tree, blob, tag + + commit contains: + + link to commits (parents) + + link to tree (commit fs root) + + meta info: commit author, email, commit msg, datetime + + tree contains: list of 3-tuple: name, perm, objid + + recursively contains tree and blob objs. + + blob contains data. (used for actually storing data) + + tag contains + + link to object (can be commit, tree, blob or other tags) + + meta info: tag author, email, tag msg, datetime + +for mercurial: + ++ *each file has its own logs*; different version of the same file, even if they have the same content, would have different "nodeid" + + this is unlike git where blobs w/ same content will have the same id ++ mercurial commits (called a "changeset") contains: + + maximum 2 parent commits (merge commits would have 2 parent commits) + + manifest: a thing that "describes the contents of the repository at a particular changeset id". basically a list of file names (full relpath) and their nodeid (i.e. a certwtain version in the history of a file) + + "A manifest describes the state of a project by listing each file and its nodeid to specify which version. Recreating a particular state means simply looking up its manifest and reconstructing the listed file versions from their revlogs." + + meta info: commit author, email, commit description, datetime + From 12de58fc9c56b76fdfd395965dee2812355cb28f Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Thu, 1 Jan 2026 05:27:14 +0000 Subject: [PATCH 16/19] feat: repo status --- templates/_repo-header.template.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/_repo-header.template.html b/templates/_repo-header.template.html index 0b29832..0be336c 100644 --- a/templates/_repo-header.template.html +++ b/templates/_repo-header.template.html @@ -8,6 +8,7 @@

{{if eq .Config.OperationMode "normal"}} + {{if eq .Repository.Status 1}}PUBLIC{{else if eq .Repository.Status 2}}PRIVATE{{else if eq .Repository.Status 4}}PUBLIC ARCHIVED{{else if eq .Repository.Status 5}}INTERNAL{{else if eq .Repository.Status 6}}LIMITED{{end}} {{if .Repository.Owner}} Owner: {{.Repository.Owner}} From 950aa01cbb1abb3a5b5376c5692e1a0595c10417 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Sat, 10 Jan 2026 15:02:44 +0800 Subject: [PATCH 17/19] feat: rrdoc --- COUNT | 2 +- docs/registration.org | 6 ++++++ pkg/aegis/config.go | 15 +++++++++++++++ routes/controller/admin/init.go | 2 ++ routes/controller/init.go | 1 + routes/controller/register.go | 9 +++++++++ templates/_footer.template.html | 2 +- templates/admin/_admin-sidebar.template.html | 1 + templates/registration.template.html | 11 +++++++++++ 9 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 docs/registration.org diff --git a/COUNT b/COUNT index d66078b..5a54564 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,104 \ No newline at end of file +v0.1.6-alpha,142 \ No newline at end of file diff --git a/docs/registration.org b/docs/registration.org new file mode 100644 index 0000000..6133b52 --- /dev/null +++ b/docs/registration.org @@ -0,0 +1,6 @@ +* user registration + +** terms of service and other similar stuff + +you must put them under the directory ~_rrdoc~ under your specified static assets directory for them to be available under the ~/rrdoc/{p}~ route; e.g. if your static assets directory is ~/opt/aegis/static~, then ~/rrdoc/toc.md~ would choose render the file ~/opt/aegis/static/_rrodc/toc.md~. (it's named "rrdoc" (reading-required documents) because these are not necessarily legal documents and can be very informal, e.g. code of conducts.) + diff --git a/pkg/aegis/config.go b/pkg/aegis/config.go index e9f652f..1f3a185 100644 --- a/pkg/aegis/config.go +++ b/pkg/aegis/config.go @@ -64,6 +64,14 @@ type AegisConfig struct { EmailConfirmationRequired bool `json:"emailConfirmationRequired"` // when set to true, all registration must be screened by the webmaster. ManualApproval bool `json:"requireManualApproval"` + // documents that users would have to read and agree to before + // registering a new account, e.g. terms of service. if "path" + // starts with "http://" or "https://", the path would be rendered + // as a link. if it's not, it would be considered as na relpath to + // `$staticAssetDirectory/rrdoc`, e.g. "Terms Of Service": + // "tos.md" links the file "$static/rrdoc/tos.md" to the title + // "Terms Of Service". + ReadingRequiredDocument []struct{Title string;Path string} `json:"readingRequiredDocument"` // git-related config. // NOTE(2025.12.30): we'll gradually move certain config options into here. @@ -342,6 +350,13 @@ func (cfg *AegisConfig) Unlock() { cfg.lock.Unlock() } +func (cfg *AegisConfig) GetRRDocTitle(p string) string { + for _, v := range cfg.ReadingRequiredDocument { + if v.Path == p { return v.Title } + } + return "" +} + const ( OP_MODE_PLAIN = "plain" OP_MODE_SIMPLE = "simple" diff --git a/routes/controller/admin/init.go b/routes/controller/admin/init.go index d7adb00..bfe3da4 100644 --- a/routes/controller/admin/init.go +++ b/routes/controller/admin/init.go @@ -3,6 +3,7 @@ package admin import ( "github.com/bctnry/aegis/routes" "github.com/bctnry/aegis/routes/controller/admin/edit_user" + "github.com/bctnry/aegis/routes/controller/admin/rrdoc" ) func BindAllAdminControllers(context *routes.RouterContext) { @@ -14,6 +15,7 @@ func BindAllAdminControllers(context *routes.RouterContext) { bindAdminReceiptSystemSettingController(context) bindAdminUserListController(context) edit_user.BindAdminEditUserController(context) + rrdoc.BindAdminRRDocController(context) bindAdminNewUserController(context) bindAdminNamespaceListController(context) bindAdminEditNamespaceController(context) diff --git a/routes/controller/init.go b/routes/controller/init.go index 195eef6..7508308 100644 --- a/routes/controller/init.go +++ b/routes/controller/init.go @@ -23,6 +23,7 @@ func InitializeRoute(context *routes.RouterContext) { bindShutdownNoticeController(context) bindMaintenanceNoticeController(context) bindPrivateNoticeController(context) + bindRRDocController(context) if context.Config.UseNamespace { bindNamespaceController(context) diff --git a/routes/controller/register.go b/routes/controller/register.go index dce085f..2fa0af0 100644 --- a/routes/controller/register.go +++ b/routes/controller/register.go @@ -76,6 +76,15 @@ func bindRegisterController(ctx *RouterContext) { })) return } + if rc.Config.ReadingRequiredDocument != nil { + for i := range rc.Config.ReadingRequiredDocument { + if len(strings.TrimSpace(r.Form.Get(fmt.Sprintf("req-%d", i)))) <= 0 { + rc.ReportRedirect("/reg", 5, "Field Required", "You must consent to all the required documents.", w, r) + return + } + } + } + password := r.Form.Get("password") passwordHash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) if err != nil { diff --git a/templates/_footer.template.html b/templates/_footer.template.html index c3c2df3..8612749 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/admin/_admin-sidebar.template.html b/templates/admin/_admin-sidebar.template.html index 76f7543..f776b3f 100644 --- a/templates/admin/_admin-sidebar.template.html +++ b/templates/admin/_admin-sidebar.template.html @@ -7,6 +7,7 @@ Receipt system config Mailer config Site lockdown + Legal documents config
Users diff --git a/templates/registration.template.html b/templates/registration.template.html index 7210332..83aa142 100644 --- a/templates/registration.template.html +++ b/templates/registration.template.html @@ -44,6 +44,17 @@

Registration

{{end}} + {{if .Config.ReadingRequiredDocument}} + {{range $k, $v := .Config.ReadingRequiredDocument}} + + + + + + + + {{end}} + {{end}} From 5997c2eeeaa4b441fb6e322ba0ef10da781a017f Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Fri, 30 Jan 2026 02:13:03 +0800 Subject: [PATCH 18/19] refactor: name change, part 1 --- COUNT | 2 +- Makefile | 8 +- README.md | 10 +- cmd/{aegis => gitus}/install.go | 46 +-- cmd/{aegis => gitus}/main.go | 66 ++-- cmd/{aegis => gitus}/reset-admin.go | 8 +- cmd/{aegis => gitus}/simple-mode.go | 32 +- cmd/{aegis => gitus}/ssh.go | 28 +- cmd/{aegis => gitus}/webhooks.go | 6 +- cmd/{aegis => gitus}/webinstaller.go | 124 +++---- devtools/generate-footer-template.go | 2 +- go.mod | 2 +- pkg/aegis/db/init/main.go | 18 - pkg/aegis/mail/mailif.go | 32 -- pkg/aegis/receipt/init/main.go | 17 - pkg/aegis/session/init/main.go | 28 -- pkg/gitlib/repository.go | 2 +- pkg/gitlib/submodule.go | 2 +- pkg/{aegis => gitus}/config.go | 124 +++---- pkg/{aegis => gitus}/confirm_code/dbif.go | 8 +- pkg/{aegis => gitus}/db/aux.go | 0 pkg/{aegis => gitus}/db/dberr.go | 0 pkg/{aegis => gitus}/db/dbif.go | 32 +- pkg/gitus/db/init/main.go | 18 + pkg/{aegis => gitus}/db/postgres/defs.go | 14 +- pkg/{aegis => gitus}/db/postgres/install.go | 2 +- pkg/{aegis => gitus}/db/postgres/query.go | 312 +++++++++--------- pkg/{aegis => gitus}/db/sqlite/defs.go | 12 +- pkg/{aegis => gitus}/db/sqlite/install.go | 2 +- pkg/{aegis => gitus}/db/sqlite/query.go | 310 ++++++++--------- pkg/{aegis => gitus}/log/main.go | 0 pkg/{aegis => gitus}/mail/gmail_plain/main.go | 10 +- pkg/gitus/mail/mailif.go | 32 ++ pkg/{aegis => gitus}/mail/smtp_plain/main.go | 10 +- pkg/{aegis => gitus}/model/acl.go | 0 pkg/{aegis => gitus}/model/issue.go | 0 pkg/{aegis => gitus}/model/keys.go | 4 +- pkg/{aegis => gitus}/model/localrepo.go | 16 +- pkg/{aegis => gitus}/model/namespace.go | 12 +- pkg/{aegis => gitus}/model/pull_request.go | 2 +- .../model/registration_request.go | 0 pkg/{aegis => gitus}/model/repository.go | 16 +- .../model/simple_mode_config.go | 0 pkg/{aegis => gitus}/model/snippet.go | 0 pkg/{aegis => gitus}/model/user.go | 32 +- pkg/{aegis => gitus}/model/webhookresult.go | 0 pkg/{aegis => gitus}/receipt/#rserr.go# | 0 pkg/gitus/receipt/init/main.go | 17 + pkg/{aegis => gitus}/receipt/postgres/main.go | 30 +- pkg/{aegis => gitus}/receipt/rsif.go | 2 +- pkg/{aegis => gitus}/receipt/sqlite/main.go | 30 +- pkg/{aegis => gitus}/session/dbif.go | 8 +- .../session/in_memory/main.go | 36 +- pkg/gitus/session/init/main.go | 28 ++ .../session/memcached/main.go | 34 +- .../session/redis_like/main.go | 34 +- .../session/sqlite/install.go | 2 +- pkg/{aegis => gitus}/session/sqlite/main.go | 32 +- .../simple_mode/repo-config.go | 16 +- pkg/{aegis => gitus}/ssh/main.go | 16 +- routes/aux.go | 4 +- routes/context.go | 32 +- routes/controller/admin/db-setting.go | 4 +- routes/controller/admin/edit-namespace.go | 8 +- routes/controller/admin/edit_user/gpg.go | 8 +- routes/controller/admin/edit_user/info.go | 10 +- routes/controller/admin/edit_user/init.go | 2 +- routes/controller/admin/edit_user/ssh.go | 8 +- routes/controller/admin/index.go | 4 +- routes/controller/admin/init.go | 6 +- routes/controller/admin/mailer-setting.go | 10 +- routes/controller/admin/namespace-list.go | 8 +- routes/controller/admin/new-user.go | 8 +- routes/controller/admin/receipt-list.go | 6 +- routes/controller/admin/reg-request.go | 8 +- routes/controller/admin/repo-list.go | 6 +- routes/controller/admin/rrdoc/delete.go | 45 +++ routes/controller/admin/rrdoc/edit.go | 101 ++++++ routes/controller/admin/rrdoc/init.go | 13 + routes/controller/admin/rrdoc/list.go | 26 ++ routes/controller/admin/rrdoc/new.go | 69 ++++ routes/controller/admin/rs-setting.go | 4 +- routes/controller/admin/session-setting.go | 4 +- routes/controller/admin/site-config.go | 4 +- routes/controller/admin/site-lockdown.go | 14 +- routes/controller/admin/user-list.go | 8 +- routes/controller/all.go | 12 +- routes/controller/aux.go | 4 +- routes/controller/blob.go | 10 +- routes/controller/branch.go | 14 +- routes/controller/commit.go | 14 +- routes/controller/confirm-registration.go | 14 +- routes/controller/diff.go | 12 +- routes/controller/dynamic-asset.go | 2 +- routes/controller/history.go | 14 +- routes/controller/http-clone.go | 18 +- routes/controller/index.go | 4 +- routes/controller/init.go | 10 +- routes/controller/issue.go | 6 +- routes/controller/label.go | 4 +- routes/controller/login.go | 16 +- routes/controller/logout.go | 6 +- routes/controller/maintenance.go | 4 +- routes/controller/namespace-setting.go | 10 +- routes/controller/namespace.go | 12 +- routes/controller/new-namespace.go | 8 +- routes/controller/new-repository.go | 6 +- routes/controller/new-snippet.go | 4 +- routes/controller/private.go | 4 +- routes/controller/receipt.go | 10 +- routes/controller/register.go | 18 +- routes/controller/repo-fork.go | 8 +- routes/controller/repo-pull-request.go | 10 +- routes/controller/repo-setting.go | 12 +- routes/controller/repository.go | 18 +- routes/controller/reset-password.go | 30 +- routes/controller/rrdoc.go | 94 ++++++ routes/controller/setting-email.go | 6 +- routes/controller/setting-gpg.go | 8 +- routes/controller/setting-privacy.go | 4 +- routes/controller/setting-ssh.go | 8 +- routes/controller/setting-user-info.go | 8 +- routes/controller/shutdown.go | 4 +- routes/controller/snippet.go | 6 +- routes/controller/tag.go | 18 +- routes/controller/tree.go | 10 +- routes/controller/user.go | 8 +- routes/controller/verify-email.go | 6 +- routes/controller/webhook-result-report.go | 6 +- routes/middleware.go | 30 +- routes/ratelimiter.go | 4 +- templates/_commit-info.model.go | 2 +- templates/_footer.template.html | 2 +- templates/_redirect/index.model.go | 2 +- templates/_repo-header.model.go | 4 +- templates/_tag-info.model.go | 2 +- templates/admin/_config.model.go | 6 +- templates/admin/index.model.go | 8 +- templates/admin/namespace-edit.model.go | 6 +- templates/admin/namespace-list.model.go | 6 +- templates/admin/receipt-list.model.go | 6 +- templates/admin/registration-request.model.go | 6 +- templates/admin/repo-list.model.go | 6 +- templates/admin/rrdoc/edit.model.go | 17 + templates/admin/rrdoc/edit.template.html | 52 +++ templates/admin/rrdoc/list.model.go | 13 + templates/admin/rrdoc/list.template.html | 53 +++ templates/admin/site-lockdown.model.go | 6 +- templates/admin/user-list.model.go | 8 +- templates/admin/user/edit-gpg-key.model.go | 8 +- templates/admin/user/edit-ssh-key.model.go | 8 +- templates/admin/user/edit.model.go | 8 +- templates/admin/user/gpg-key.model.go | 10 +- templates/admin/user/ssh-key.model.go | 10 +- templates/all/namespace-list.model.go | 6 +- templates/all/repository-list.model.go | 6 +- templates/commit-history.model.go | 6 +- templates/depot-namespace.model.go | 6 +- templates/depot-no-namespace.model.go | 4 +- templates/diff.model.go | 6 +- templates/edit-file.model.go | 4 +- templates/error.model.go | 4 +- templates/file.model.go | 6 +- templates/fork.model.go | 6 +- templates/getRRDocHref.func.go | 16 + templates/getRepoSSH.func.go | 6 +- templates/rrdoc.model.go | 13 + templates/rrdoc.template.html | 23 ++ templates/snippet/setting.model.go | 8 +- templates/tag.model.go | 8 +- templates/toFuzzyTime.func.go | 2 +- templates/tree.model.go | 6 +- templates/upload-file.model.go | 4 +- templates/user-snippet-list.model.go | 8 +- templates/user.model.go | 8 +- templates/webinstaller/webinstaller.model.go | 4 +- 176 files changed, 1792 insertions(+), 1257 deletions(-) rename cmd/{aegis => gitus}/install.go (91%) rename cmd/{aegis => gitus}/main.go (82%) rename cmd/{aegis => gitus}/reset-admin.go (84%) rename cmd/{aegis => gitus}/simple-mode.go (87%) rename cmd/{aegis => gitus}/ssh.go (88%) rename cmd/{aegis => gitus}/webhooks.go (98%) rename cmd/{aegis => gitus}/webinstaller.go (91%) delete mode 100644 pkg/aegis/db/init/main.go delete mode 100644 pkg/aegis/mail/mailif.go delete mode 100644 pkg/aegis/receipt/init/main.go delete mode 100644 pkg/aegis/session/init/main.go rename pkg/{aegis => gitus}/config.go (87%) rename pkg/{aegis => gitus}/confirm_code/dbif.go (72%) rename pkg/{aegis => gitus}/db/aux.go (100%) rename pkg/{aegis => gitus}/db/dberr.go (100%) rename pkg/{aegis => gitus}/db/dbif.go (92%) create mode 100644 pkg/gitus/db/init/main.go rename pkg/{aegis => gitus}/db/postgres/defs.go (75%) rename pkg/{aegis => gitus}/db/postgres/install.go (98%) rename pkg/{aegis => gitus}/db/postgres/query.go (91%) rename pkg/{aegis => gitus}/db/sqlite/defs.go (78%) rename pkg/{aegis => gitus}/db/sqlite/install.go (98%) rename pkg/{aegis => gitus}/db/sqlite/query.go (92%) rename pkg/{aegis => gitus}/log/main.go (100%) rename pkg/{aegis => gitus}/mail/gmail_plain/main.go (74%) create mode 100644 pkg/gitus/mail/mailif.go rename pkg/{aegis => gitus}/mail/smtp_plain/main.go (76%) rename pkg/{aegis => gitus}/model/acl.go (100%) rename pkg/{aegis => gitus}/model/issue.go (100%) rename pkg/{aegis => gitus}/model/keys.go (79%) rename pkg/{aegis => gitus}/model/localrepo.go (93%) rename pkg/{aegis => gitus}/model/namespace.go (89%) rename pkg/{aegis => gitus}/model/pull_request.go (97%) rename pkg/{aegis => gitus}/model/registration_request.go (100%) rename pkg/{aegis => gitus}/model/repository.go (88%) rename pkg/{aegis => gitus}/model/simple_mode_config.go (100%) rename pkg/{aegis => gitus}/model/snippet.go (100%) rename pkg/{aegis => gitus}/model/user.go (60%) rename pkg/{aegis => gitus}/model/webhookresult.go (100%) rename pkg/{aegis => gitus}/receipt/#rserr.go# (100%) create mode 100644 pkg/gitus/receipt/init/main.go rename pkg/{aegis => gitus}/receipt/postgres/main.go (85%) rename pkg/{aegis => gitus}/receipt/rsif.go (98%) rename pkg/{aegis => gitus}/receipt/sqlite/main.go (86%) rename pkg/{aegis => gitus}/session/dbif.go (75%) rename pkg/{aegis => gitus}/session/in_memory/main.go (76%) create mode 100644 pkg/gitus/session/init/main.go rename pkg/{aegis => gitus}/session/memcached/main.go (80%) rename pkg/{aegis => gitus}/session/redis_like/main.go (74%) rename pkg/{aegis => gitus}/session/sqlite/install.go (87%) rename pkg/{aegis => gitus}/session/sqlite/main.go (77%) rename pkg/{aegis => gitus}/simple_mode/repo-config.go (82%) rename pkg/{aegis => gitus}/ssh/main.go (89%) create mode 100644 routes/controller/admin/rrdoc/delete.go create mode 100644 routes/controller/admin/rrdoc/edit.go create mode 100644 routes/controller/admin/rrdoc/init.go create mode 100644 routes/controller/admin/rrdoc/list.go create mode 100644 routes/controller/admin/rrdoc/new.go create mode 100644 routes/controller/rrdoc.go create mode 100644 templates/admin/rrdoc/edit.model.go create mode 100644 templates/admin/rrdoc/edit.template.html create mode 100644 templates/admin/rrdoc/list.model.go create mode 100644 templates/admin/rrdoc/list.template.html create mode 100644 templates/getRRDocHref.func.go create mode 100644 templates/rrdoc.model.go create mode 100644 templates/rrdoc.template.html diff --git a/COUNT b/COUNT index 5a54564..794fd1a 100644 --- a/COUNT +++ b/COUNT @@ -1 +1 @@ -v0.1.6-alpha,142 \ No newline at end of file +v0.1.6-alpha,151 \ No newline at end of file diff --git a/Makefile b/Makefile index a5d56b3..0221b3d 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ clean: - if [ -f "aegis" ]; then rm ./aegis; fi + if [ -f "gitus" ]; then rm ./gitus; fi -aegis-web-server: +gitus-web-server: go run ./devtools/generate-template.go templates go run ./devtools/generate-footer-template.go go run ./devtools/embed-static.go ./static templates - go build ./cmd/aegis + go build ./cmd/gitus all: - make aegis-web-server + make gitus-web-server diff --git a/README.md b/README.md index cbf763f..461168b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ Aegis Logo -# Aegis +# Gitus -Aegis is a self-hosted code forge that mainly supports the Git distributed version control system. +Gitus is a self-hosted code forge that mainly supports the Git distributed version control system. + Simple, functional UI; + **No JavaScript** - works all major browsers and a lot of minor ones, including [Ladybird](https://ladybird.org), [K-Meleon](http://kmeleonbrowser.org) and [NetSurf](https://www.netsurf-browser.org). @@ -40,7 +40,7 @@ make all Run the following command: ``` sh -./aegis -init +./gitus -init ``` And choose to start the web installer. It will guide you through the configuration process. @@ -48,7 +48,7 @@ And choose to start the web installer. It will guide you through the configurati After the configuration process, run: ``` sh -./aegis -config {config_file_path} +./gitus -config {config_file_path} ``` This would set up everything that's required. After the setup process is completed, run the same command again to start the "main" web server. @@ -56,7 +56,7 @@ This would set up everything that's required. After the setup process is complet This process would show you the password for the admin user, which is randomly generated. You can override this password by running: ``` sh -./aegis -config {config_file_path} reset-admin +./gitus -config {config_file_path} reset-admin ``` Currently Aegis only supports the following systems for its components; support for other systems are planned: diff --git a/cmd/aegis/install.go b/cmd/gitus/install.go similarity index 91% rename from cmd/aegis/install.go rename to cmd/gitus/install.go index 9fd2879..7fbc858 100644 --- a/cmd/aegis/install.go +++ b/cmd/gitus/install.go @@ -14,10 +14,10 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) @@ -69,7 +69,7 @@ func createOtherOwnedDirectory(p string, uids string, gids string) error { return nil } -func normalModeAegisReadyCheck(ctx routes.RouterContext) (bool, error) { +func normalModeGitusReadyCheck(ctx routes.RouterContext) (bool, error) { dbif := ctx.DatabaseInterface ssif := ctx.SessionInterface cfg := ctx.Config @@ -149,13 +149,13 @@ func askString(prompt string, defaultResult string) (string, error) { func gitUserSetupCheckPrompt() { fmt.Println() fmt.Printf("You need to check if the Git user is set up properly:\n") - fmt.Printf("1. Make sure that both the Git user and the user running Aegis has full read/write permission of the Git Root specified in the config file\n") - fmt.Printf("2. Make sure that the user running Aegis has full read/write permission of the `.ssh/authorized_keys` file under the home directory of the Git user. \n") + fmt.Printf("1. Make sure that both the Git user and the user running Gitus has full read/write permission of the Git Root specified in the config file\n") + fmt.Printf("2. Make sure that the user running Gitus has full read/write permission of the `.ssh/authorized_keys` file under the home directory of the Git user. \n") fmt.Printf("3. Make sure the git shell commands are properly set up. This includes:\n") fmt.Printf(" 1. A `git-shell-command` directory exists under the home directory of the Git user.\n") - fmt.Printf(" 2. A `no-interactive-login` file exists under the `git-shell-command` directory. This file needs to be executable. This is used to stop the original git-shell from providing things. It can be a simple shell script that calls the command `aegis no-login`.\n") - fmt.Printf(" 3. The `aegis` executable should be under the `git-shell-command` directory as well.\n") - fmt.Printf("4. Make sure that the Aegis user can access the static assets directory\n") + fmt.Printf(" 2. A `no-interactive-login` file exists under the `git-shell-command` directory. This file needs to be executable. This is used to stop the original git-shell from providing things. It can be a simple shell script that calls the command `gitus no-login`.\n") + fmt.Printf(" 3. The `gitus` executable should be under the `git-shell-command` directory as well.\n") + fmt.Printf("4. Make sure that the Gitus user can access the static assets directory\n") } func gitUserCheck(ctx routes.RouterContext) bool { @@ -262,36 +262,36 @@ func gitUserCheck(ctx routes.RouterContext) bool { gitUserSetupCheckPrompt(); return false } - // copy aegis executable... for handling git over ssh. + // copy gitus executable... for handling git over ssh. s, err := os.Executable() if err != nil { - fmt.Printf("Failed to copy Aegis executable: %s\n", err.Error()) + fmt.Printf("Failed to copy Gitus executable: %s\n", err.Error()) gitUserSetupCheckPrompt(); return false } - aegisPath := path.Join(homeDir, "git-shell-commands", "aegis") - if aegisPath == s { return true } + gitusPath := path.Join(homeDir, "git-shell-commands", "gitus") + if gitusPath == s { return true } f, err := os.Open(s) if err != nil { - fmt.Printf("Failed to copy Aegis executable: %s\n", err.Error()) + fmt.Printf("Failed to copy Gitus executable: %s\n", err.Error()) gitUserSetupCheckPrompt(); return false } defer f.Close() - fout, err := os.OpenFile(aegisPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0754) + fout, err := os.OpenFile(gitusPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0754) if err != nil { - fmt.Printf("Failed to copy Aegis executable: %s\n", err.Error()) + fmt.Printf("Failed to copy Gitus executable: %s\n", err.Error()) gitUserSetupCheckPrompt(); return false } defer fout.Close() _, err = io.Copy(fout, f) if err != nil { - fmt.Printf("Failed to copy Aegis executable: %s\n", err.Error()) + fmt.Printf("Failed to copy Gitus executable: %s\n", err.Error()) gitUserSetupCheckPrompt(); return false } guUid, _ := strconv.Atoi(gitUser.Uid) guGid, _ := strconv.Atoi(gitUser.Gid) - err = os.Chown(aegisPath, guUid, guGid) + err = os.Chown(gitusPath, guUid, guGid) if err != nil { - fmt.Printf("Failed to chown Aegis executable: %s\n", err.Error()) + fmt.Printf("Failed to chown Gitus executable: %s\n", err.Error()) gitUserSetupCheckPrompt(); return false } fmt.Printf("Done.\n") @@ -301,7 +301,7 @@ func gitUserCheck(ctx routes.RouterContext) bool { // NOTE: you shouldn't check for plain mode here (instead - check it // at the *caller* side!) since plain mode is fully "passive" and will // not involve any database setup. -func InstallAegis(ctx routes.RouterContext) { +func InstallGitus(ctx routes.RouterContext) { if len(strings.TrimSpace(ctx.Config.GitUser)) <= 0 { fmt.Printf("Plain mode disabled but empty Git user name... this won't do. We'll assume the name of the Git user is `git`.\n") gitUserName := "git" @@ -437,7 +437,7 @@ func InstallAegis(ctx routes.RouterContext) { } fmt.Print(`Admin user setup complete. Please use the reset-admin command to change the password: - aegis -config [config-path] reset-admin + gitus -config [config-path] reset-admin `) } @@ -447,7 +447,7 @@ func InstallAegis(ctx routes.RouterContext) { // when we reached here, gitUser shouldn't be nil, since if it's nil we // would've created it with the code above. gitUser, _ := user.Lookup(ctx.Config.GitUser) - staticPath := path.Join(gitUser.HomeDir, "aegis-static") + staticPath := path.Join(gitUser.HomeDir, "gitus-static") err = templates.UnpackStaticFileTo(staticPath) if err != nil { fmt.Printf("Failed to setup static assets: %s\n", err.Error()) diff --git a/cmd/aegis/main.go b/cmd/gitus/main.go similarity index 82% rename from cmd/aegis/main.go rename to cmd/gitus/main.go index dbe695d..1194e2b 100644 --- a/cmd/aegis/main.go +++ b/cmd/gitus/main.go @@ -13,23 +13,23 @@ import ( "syscall" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/confirm_code" - dbinit "github.com/bctnry/aegis/pkg/aegis/db/init" - "github.com/bctnry/aegis/pkg/aegis/mail" - rsinit "github.com/bctnry/aegis/pkg/aegis/receipt/init" - ssinit "github.com/bctnry/aegis/pkg/aegis/session/init" - "github.com/bctnry/aegis/pkg/aegis/ssh" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/routes/controller" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/confirm_code" + dbinit "github.com/GitusCodeForge/Gitus/pkg/gitus/db/init" + "github.com/GitusCodeForge/Gitus/pkg/gitus/mail" + rsinit "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt/init" + ssinit "github.com/GitusCodeForge/Gitus/pkg/gitus/session/init" + "github.com/GitusCodeForge/Gitus/pkg/gitus/ssh" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/routes/controller" + "github.com/GitusCodeForge/Gitus/templates" ) func main() { - argparse := flag.NewFlagSet("aegis", flag.ContinueOnError) + argparse := flag.NewFlagSet("gitus", flag.ContinueOnError) argparse.Usage = func() { - fmt.Fprintf(argparse.Output(), "Usage: aegis [flags] [config]\n") + fmt.Fprintf(argparse.Output(), "Usage: gitus [flags] [config]\n") argparse.PrintDefaults() } initFlag := argparse.Bool("init", false, "Create an initial configuration file at the location specified with [config].") @@ -59,7 +59,7 @@ func main() { WebInstaller() os.Exit(0) } - err := aegis.CreateConfigFile(configPath) + err := gitus.CreateConfigFile(configPath) if err != nil { fmt.Fprintf(os.Stderr, "Failed to create configuration file: %s\n", err.Error()) os.Exit(1) @@ -69,7 +69,7 @@ func main() { } mainCall := argparse.Args() - // NOTE THAT certain activities does not need parts of Aegis + // NOTE THAT certain activities does not need parts of Gitus // (e.g. "ssh" and "webhooks" does not require a working mailer // or session store). We've decided they should not report // error when we're not able to initialize them in this case. @@ -86,7 +86,7 @@ func main() { mailerNeeded := isWebServer ccmNeeded := isWebServer - config, err := aegis.LoadConfigFile(configPath) + config, err := gitus.LoadConfigFile(configPath) noConfig := err != nil // we use the same executable for the web server and the ssh // handling command. both use cases requires a proper config @@ -110,7 +110,7 @@ func main() { } // if it's in normal mode we need to setup database. - if config.OperationMode == aegis.OP_MODE_NORMAL { + if config.OperationMode == gitus.OP_MODE_NORMAL { if dbifNeeded { dbif, err := dbinit.InitializeDatabase(config) if err != nil { @@ -133,7 +133,7 @@ func main() { keyctx, err := ssh.ToContext(config) if err != nil { fmt.Fprintf(os.Stderr, "Failed to create key managing context: %s\n", err.Error()) - fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Aegis again, or else you might not be able to clone/push through SSH.\n") + fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Gitus again, or else you might not be able to clone/push through SSH.\n") os.Exit(1) } context.SSHKeyManagingContext = keyctx @@ -143,7 +143,7 @@ func main() { rs, err := rsinit.InitializeReceiptSystem(config) if err != nil { fmt.Fprintf(os.Stderr, "Failed to create receipt system interface: %s\n", err.Error()) - fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Aegis again, or things like user registration & password resetting wouldn't work properly.\n") + fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Gitus again, or things like user registration & password resetting wouldn't work properly.\n") os.Exit(1) } context.ReceiptSystem = rs @@ -153,7 +153,7 @@ func main() { ml, err := mail.InitializeMailer(config) if err != nil { fmt.Fprintf(os.Stderr, "Failed to create mailer interface: %s\n", err.Error()) - fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Aegis again, or things thar depends on sending emails wouldn't work properly.\n") + fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Gitus again, or things thar depends on sending emails wouldn't work properly.\n") } context.Mailer = ml } @@ -162,15 +162,15 @@ func main() { ccm, err := confirm_code.InitializeConfirmCodeManager(config) if err != nil { fmt.Fprintf(os.Stderr, "Failed to create confirm code manager: %s\n", err.Error()) - fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Aegis again, or things thar depends on sending emails wouldn't work properly.\n") + fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Gitus again, or things thar depends on sending emails wouldn't work properly.\n") } context.ConfirmCodeManager = ccm } - ok, err := normalModeAegisReadyCheck(context) + ok, err := normalModeGitusReadyCheck(context) if !ok { - fmt.Fprintf(os.Stderr, "Aegis Ready Check failed: %s\n", err.Error()) - InstallAegis(context) + fmt.Fprintf(os.Stderr, "Gitus Ready Check failed: %s\n", err.Error()) + InstallGitus(context) os.Exit(1) } } @@ -178,7 +178,7 @@ func main() { gitUser, err := user.Lookup(context.Config.GitUser) if err != nil { fmt.Fprintf(os.Stderr, "Failed to find Git user %s: %s\n", context.Config.GitUser, err.Error()) - fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Aegis again, or else you might not be able to clone/push through SSH.\n") + fmt.Fprintf(os.Stderr, "You should try to fix the problem and run Gitus again, or else you might not be able to clone/push through SSH.\n") os.Exit(1) } context.GitUserHomeDirectory = gitUser.HomeDir @@ -192,7 +192,7 @@ func main() { fmt.Fprintf(os.Stderr, "No config file specified. Cannot continue.\n") } else { fmt.Println(mainCall) - InstallAegis(context) + InstallGitus(context) } return case "reset-admin": @@ -204,33 +204,33 @@ func main() { return case "ssh": if len(mainCall) < 3 { - fmt.Print(gitlib.ToPktLine("Error format for `aegis ssh`.")) + fmt.Print(gitlib.ToPktLine("Error format for `gitus ssh`.")) return } HandleSSHLogin(&context, mainCall[1], mainCall[2]) return case "simple-mode": if len(mainCall) < 3 { - fmt.Print(gitlib.ToPktLine("Error format for `aegis simple-mode`.")) + fmt.Print(gitlib.ToPktLine("Error format for `gitus simple-mode`.")) return } HandleSimpleMode(&context, mainCall[1], mainCall[2]) return case "web-hooks": if len(mainCall) < 7 { - fmt.Print(gitlib.ToPktLine("Error format for `aegis web-hooks`.")) + fmt.Print(gitlib.ToPktLine("Error format for `gitus web-hooks`.")) return } switch mainCall[1] { case "send": HandleWebHook(&context, mainCall[2], mainCall[3], mainCall[4], mainCall[5], mainCall[6]) default: - fmt.Print(gitlib.ToPktLine(fmt.Sprintf("Error command for `aegis web-hooks`: %s.", mainCall[1]))) + fmt.Print(gitlib.ToPktLine(fmt.Sprintf("Error command for `gitus web-hooks`: %s.", mainCall[1]))) } return case "update-trigger": if len(mainCall) < 6 { - fmt.Print(gitlib.ToPktLine("Error format for `aegis-update-trigger`.")) + fmt.Print(gitlib.ToPktLine("Error format for `gitus-update-trigger`.")) return } HandleUpdateTrigger(&context, mainCall[1], mainCall[2], mainCall[3], mainCall[4], mainCall[5]) @@ -300,8 +300,8 @@ func main() { } } - if context.Config.OperationMode == aegis.OP_MODE_SIMPLE { - os.RemoveAll(path.Join(gitUser.HomeDir, "aegis.sock")) + if context.Config.OperationMode == gitus.OP_MODE_SIMPLE { + os.RemoveAll(path.Join(gitUser.HomeDir, "gitus.sock")) } log.Println("Graceful shutdown complete.") diff --git a/cmd/aegis/reset-admin.go b/cmd/gitus/reset-admin.go similarity index 84% rename from cmd/aegis/reset-admin.go rename to cmd/gitus/reset-admin.go index fdd07c4..c128dbe 100644 --- a/cmd/aegis/reset-admin.go +++ b/cmd/gitus/reset-admin.go @@ -4,15 +4,15 @@ import ( "fmt" "os" - "github.com/bctnry/aegis/pkg/aegis" - dbinit "github.com/bctnry/aegis/pkg/aegis/db/init" - "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + dbinit "github.com/GitusCodeForge/Gitus/pkg/gitus/db/init" + "github.com/GitusCodeForge/Gitus/routes" "golang.org/x/crypto/bcrypt" "golang.org/x/term" ) func ResetAdmin(ctx *routes.RouterContext) { - if ctx.Config.OperationMode != aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode != gitus.OP_MODE_NORMAL { // TODO: add more info about how to set things up in simple mode. fmt.Printf("Configuration not in normal mode.") return diff --git a/cmd/aegis/simple-mode.go b/cmd/gitus/simple-mode.go similarity index 87% rename from cmd/aegis/simple-mode.go rename to cmd/gitus/simple-mode.go index 639a983..9bb4e93 100644 --- a/cmd/aegis/simple-mode.go +++ b/cmd/gitus/simple-mode.go @@ -7,24 +7,24 @@ import ( "os/exec" "path" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/aegis/ssh" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/pkg/shellparse" - "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus/ssh" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/shellparse" + "github.com/GitusCodeForge/Gitus/routes" ) // handles: -// aegis simple-mode keys-update $newrev -// aegis simple-mode config-update $newrev -// aegis simple-mode aegis-sync $path +// gitus simple-mode keys-update $newrev +// gitus simple-mode config-update $newrev +// gitus simple-mode gitus-sync $path func syncSimpleModeCache(ctx *routes.RouterContext) error { - aegisSyncDir := path.Join(ctx.Config.GitRoot, "__aegis", "__repo_config", "aegis_sync") + gitusSyncDir := path.Join(ctx.Config.GitRoot, "__gitus", "__repo_config", "gitus_sync") if ctx.SimpleModeConfigCache == nil { ctx.SimpleModeConfigCache = make(map[string]*model.SimpleModeNamespaceConfig, 0) } - lst, err := os.ReadDir(aegisSyncDir) + lst, err := os.ReadDir(gitusSyncDir) if err != nil { return err } if !ctx.Config.UseNamespace { ctx.SimpleModeConfigCache[""] = new(model.SimpleModeNamespaceConfig) @@ -33,7 +33,7 @@ func syncSimpleModeCache(ctx *routes.RouterContext) error { if !v.IsDir() { continue } if !model.ValidRepositoryName(v.Name()) { continue } repoName := v.Name() - repoDir := path.Join(aegisSyncDir, repoName) + repoDir := path.Join(gitusSyncDir, repoName) concreteRepoPath := path.Join(ctx.Config.GitRoot, repoName) os.MkdirAll(concreteRepoPath, 0755) repoConfPath := path.Join(repoDir, "config.json") @@ -48,7 +48,7 @@ func syncSimpleModeCache(ctx *routes.RouterContext) error { if !v.IsDir() { continue } if !model.ValidNamespaceName(v.Name()) { continue } nsName := v.Name() - nsDir := path.Join(aegisSyncDir, nsName) + nsDir := path.Join(gitusSyncDir, nsName) concreteNsPath := path.Join(ctx.Config.GitRoot, nsName) os.MkdirAll(concreteNsPath, 0755) nsConfigPath := path.Join(nsDir, "config.json") @@ -100,7 +100,7 @@ func HandleSimpleMode(ctx *routes.RouterContext, cmd string, newRev string) { } ctx.SSHKeyManagingContext = sshCtx nsName := "" - if ctx.Config.UseNamespace { nsName = "__aegis" } + if ctx.Config.UseNamespace { nsName = "__gitus" } repoName := "__keys" p := path.Join(ctx.Config.GitRoot, nsName, repoName) keyGitRepo, err := model.CreateLocalRepository(model.REPO_TYPE_GIT, nsName, repoName, p) @@ -146,7 +146,7 @@ func HandleSimpleMode(ctx *routes.RouterContext, cmd string, newRev string) { return } - case "aegis-sync": + case "gitus-sync": // see docs/simple-mode.org cmd := exec.Command("git", "pull") cmd.Dir = newRev @@ -158,12 +158,12 @@ func HandleSimpleMode(ctx *routes.RouterContext, cmd string, newRev string) { cmd.Stderr = stderrBuf err := cmd.Run() if err != nil { - printGitError(fmt.Sprintf("Failed to run git pull at aegis_sync: %s; %s; %s", err, stderrBuf.String(), stdoutBuf.String())) + printGitError(fmt.Sprintf("Failed to run git pull at gitus_sync: %s; %s; %s", err, stderrBuf.String(), stdoutBuf.String())) return } err = syncSimpleModeCache(ctx) if err != nil { - printGitError(fmt.Sprintf("Failed to run git pull at aegis_sync: %s", err)) + printGitError(fmt.Sprintf("Failed to run git pull at gitus_sync: %s", err)) return } diff --git a/cmd/aegis/ssh.go b/cmd/gitus/ssh.go similarity index 88% rename from cmd/aegis/ssh.go rename to cmd/gitus/ssh.go index 91f87d5..e1fde4b 100644 --- a/cmd/aegis/ssh.go +++ b/cmd/gitus/ssh.go @@ -7,15 +7,15 @@ import ( "path" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/aegis/ssh" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/pkg/shellparse" - "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus/ssh" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/shellparse" + "github.com/GitusCodeForge/Gitus/routes" ) -// `aegis ssh` handler. +// `gitus ssh` handler. func printGitError(s string) { fmt.Print(gitlib.ToPktLine(fmt.Sprintf("ERR %s\n", s))) @@ -68,9 +68,9 @@ func handleSSHSimpleMode(ctx *routes.RouterContext, username string, keyname str namespaceName, repositoryName := parseTargetRepositoryName(ctx, relPath) var configRelPath string if ctx.Config.UseNamespace { - configRelPath = path.Join("__aegis", "__repo_config", "aegis_sync") + configRelPath = path.Join("__gitus", "__repo_config", "gitus_sync") } else { - configRelPath = path.Join("__repo_config", "aegis_sync") + configRelPath = path.Join("__repo_config", "gitus_sync") } configPath := path.Join(ctx.Config.GitRoot, configRelPath, namespaceName, repositoryName, "config.json") config, err := model.ReadRepositoryConfigFromFile(configPath) @@ -120,17 +120,17 @@ func handleSSHSimpleMode(ctx *routes.RouterContext, username string, keyname str } func HandleSSHLogin(ctx *routes.RouterContext, username string, keyname string) { - if ctx.Config.OperationMode == aegis.OP_MODE_SIMPLE { + if ctx.Config.OperationMode == gitus.OP_MODE_SIMPLE { handleSSHSimpleMode(ctx, username, keyname) return } if ctx.Config.IsInPlainMode() { - printGitError("This instance of Aegis is in Plain Mode which does not allow Git over SSH.") + printGitError("This instance of Gitus is in Plain Mode which does not allow Git over SSH.") os.Exit(1) } - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC && - ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PRIVATE { - printGitError("This instance of Aegis is currently unavailable.") + if ctx.Config.GlobalVisibility != gitus.GLOBAL_VISIBILITY_PUBLIC && + ctx.Config.GlobalVisibility != gitus.GLOBAL_VISIBILITY_PRIVATE { + printGitError("This instance of Gitus is currently unavailable.") os.Exit(1) } m, err := ctx.DatabaseInterface.GetAuthKeyByName(username, keyname) diff --git a/cmd/aegis/webhooks.go b/cmd/gitus/webhooks.go similarity index 98% rename from cmd/aegis/webhooks.go rename to cmd/gitus/webhooks.go index 7845465..7224c19 100644 --- a/cmd/aegis/webhooks.go +++ b/cmd/gitus/webhooks.go @@ -11,9 +11,9 @@ import ( "strings" "time" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" "github.com/golang-jwt/jwt/v5" "github.com/google/uuid" ) diff --git a/cmd/aegis/webinstaller.go b/cmd/gitus/webinstaller.go similarity index 91% rename from cmd/aegis/webinstaller.go rename to cmd/gitus/webinstaller.go index 28ed232..a29c084 100644 --- a/cmd/aegis/webinstaller.go +++ b/cmd/gitus/webinstaller.go @@ -18,16 +18,16 @@ import ( "syscall" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/db" - dbinit "github.com/bctnry/aegis/pkg/aegis/db/init" - "github.com/bctnry/aegis/pkg/aegis/model" - rsinit "github.com/bctnry/aegis/pkg/aegis/receipt/init" - ssinit "github.com/bctnry/aegis/pkg/aegis/session/init" - "github.com/bctnry/aegis/pkg/auxfuncs" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/pkg/shellparse" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + dbinit "github.com/GitusCodeForge/Gitus/pkg/gitus/db/init" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + rsinit "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt/init" + ssinit "github.com/GitusCodeForge/Gitus/pkg/gitus/session/init" + "github.com/GitusCodeForge/Gitus/pkg/auxfuncs" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/shellparse" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) @@ -49,7 +49,7 @@ type WebInstallerRoutingContext struct { // depot name // rate limiter // front page config - // (static assets dir default to be $HOME/aegis-static/) + // (static assets dir default to be $HOME/gitus-static/) // bind address & port // http host name // ssh host name (disabled if plain mode) @@ -62,7 +62,7 @@ type WebInstallerRoutingContext struct { // simple mode: 1-6-8-10 // normal mode: 1-2-3-4-5-6-8-9 Step int - Config *aegis.AegisConfig + Config *gitus.GitusConfig ConfirmStageReached bool ResultingFilePath string GitUserHome string @@ -127,11 +127,11 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { ctx.Config.OperationMode = om ctx.Config.UseNamespace = len(r.Form.Get("enable-namespace")) > 0 switch ctx.Config.OperationMode { - case aegis.OP_MODE_NORMAL: + case gitus.OP_MODE_NORMAL: foundAt(w, "/step2") - case aegis.OP_MODE_PLAIN: + case gitus.OP_MODE_PLAIN: foundAt(w, "/step6") - case aegis.OP_MODE_SIMPLE: + case gitus.OP_MODE_SIMPLE: foundAt(w, "/step6") } })) @@ -148,7 +148,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { ctx.reportRedirect("/step2", 0, "Invalid Request", "The request is of an invalid form. Please try again.", w) return } - ctx.Config.Database = aegis.AegisDatabaseConfig{ + ctx.Config.Database = gitus.GitusDatabaseConfig{ Type: strings.TrimSpace(r.Form.Get("database-type")), Path: strings.TrimSpace(r.Form.Get("database-path")), URL: strings.TrimSpace(r.Form.Get("database-url")), @@ -178,7 +178,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { ctx.reportRedirect("/step3", 0, "Invalid Request", "The request is of an invalid form. Please try again.", w) return } - ctx.Config.Session = aegis.AegisSessionConfig{ + ctx.Config.Session = gitus.GitusSessionConfig{ Type: strings.TrimSpace(r.Form.Get("session-type")), Path: strings.TrimSpace(r.Form.Get("session-path")), TablePrefix: strings.TrimSpace(r.Form.Get("session-table-prefix")), @@ -208,7 +208,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { ctx.reportRedirect("/step4", 0, "Invalid Request", "The request is of an invalid form. Please try again.", w) return } - ctx.Config.Mailer = aegis.AegisMailerConfig{ + ctx.Config.Mailer = gitus.GitusMailerConfig{ Type: strings.TrimSpace(r.Form.Get("mailer-type")), SMTPServer: strings.TrimSpace(r.Form.Get("mailer-smtp-server")), SMTPPort: int(i), @@ -231,7 +231,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { ctx.reportRedirect("/step5", 0, "Invalid Request", "The request is of an invalid form. Please try again.", w) return } - ctx.Config.ReceiptSystem = aegis.AegisReceiptSystemConfig{ + ctx.Config.ReceiptSystem = gitus.GitusReceiptSystemConfig{ Type: strings.TrimSpace(r.Form.Get("receipt-system-type")), Path: strings.TrimSpace(r.Form.Get("receipt-system-path")), URL: strings.TrimSpace(r.Form.Get("receipt-system-url")), @@ -326,7 +326,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { ctx.Config.Theme.ForegroundColor = "#000000" ctx.Config.Theme.BackgroundColor = "#ffffff" // NOTE: these options are not used in plain mode and simple mode. - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { ctx.Config.AllowRegistration = len(strings.TrimSpace(r.Form.Get("allow-registration"))) > 0 ctx.Config.EmailConfirmationRequired = len(strings.TrimSpace(r.Form.Get("email-confirmation-required"))) > 0 ctx.Config.ManualApproval = len(strings.TrimSpace(r.Form.Get("manual-approval"))) > 0 @@ -335,7 +335,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { ctx.reportRedirect("/step8", 0, "Invalid Request", "The request is of an invalid form. Please try again.", w) return } - ctx.Config.DefaultNewUserStatus = model.AegisUserStatus(us) + ctx.Config.DefaultNewUserStatus = model.GitusUserStatus(us) ctx.Config.DefaultNewUserNamespace = strings.TrimSpace(r.Form.Get("default-new-user-namespace")) } maxr, err := strconv.ParseFloat(strings.TrimSpace(r.Form.Get("max-request-in-second")), 64) @@ -345,11 +345,11 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { } ctx.Config.MaxRequestInSecond = maxr switch ctx.Config.OperationMode { - case aegis.OP_MODE_PLAIN: + case gitus.OP_MODE_PLAIN: foundAt(w, "/confirm") - case aegis.OP_MODE_SIMPLE: + case gitus.OP_MODE_SIMPLE: foundAt(w, "/step10") - case aegis.OP_MODE_NORMAL: + case gitus.OP_MODE_NORMAL: foundAt(w, "/step9") } })) @@ -407,13 +407,13 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { - Codestin Search App`) + Codestin Search App`) ctx.loadTemplate("webinstaller/_style").Execute(w, nil) fmt.Fprint(w, `
-

Aegis Web Installer

+

Gitus Web Installer

  • Step 1: Operation Mode & Enabling Namespace
  • Step 2: Database Config
  • @@ -449,7 +449,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { return false } homePath := fmt.Sprintf("/home/%s", ctx.Config.GitUser) - ctx.Config.StaticAssetDirectory = path.Join(homePath, "aegis-static-assets") + ctx.Config.StaticAssetDirectory = path.Join(homePath, "gitus-static-assets") err = os.MkdirAll(homePath, os.ModeDir|0755) if err != nil { fmt.Fprintf(w, "

    Failed to create home directory for user %s: %s

    ", ctx.Config.GitUser, homePath) @@ -509,36 +509,36 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { fmt.Fprintf(w, "

    Failed to create the authorized_keys file: %s

    ", err.Error()) return false } - fmt.Fprint(w, "

    Copying aegis executable...

    ") + fmt.Fprint(w, "

    Copying gitus executable...

    ") s, err := os.Executable() if err != nil { - fmt.Fprintf(w, "

    Failed to copy Aegis executable: %s

    ", err.Error()) + fmt.Fprintf(w, "

    Failed to copy Gitus executable: %s

    ", err.Error()) return false } - aegisPath := path.Join(homePath, "git-shell-commands", "aegis") - if aegisPath == s { + gitusPath := path.Join(homePath, "git-shell-commands", "gitus") + if gitusPath == s { fmt.Fprint(w, "

    Seems like executable already exists. Not copying...

    \n") } else { f, err := os.Open(s) if err != nil { - fmt.Fprintf(w, "

    Failed to copy Aegis executable: %s

    ", err.Error()) + fmt.Fprintf(w, "

    Failed to copy Gitus executable: %s

    ", err.Error()) return false } defer f.Close() - fout, err := os.OpenFile(aegisPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0754) + fout, err := os.OpenFile(gitusPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0754) if err != nil { - fmt.Fprintf(w, "

    Failed to copy Aegis executable: %s\n

    ", err.Error()) + fmt.Fprintf(w, "

    Failed to copy Gitus executable: %s\n

    ", err.Error()) return false } defer fout.Close() _, err = io.Copy(fout, f) if err != nil { - fmt.Fprintf(w, "

    Failed to copy Aegis executable: %s\n

    ", err.Error()) + fmt.Fprintf(w, "

    Failed to copy Gitus executable: %s\n

    ", err.Error()) return false } - err = os.Chown(aegisPath, uid, gid) + err = os.Chown(gitusPath, uid, gid) if err != nil { - fmt.Fprintf(w, "

    Failed to copy Aegis executable: %s\n

    ", err.Error()) + fmt.Fprintf(w, "

    Failed to copy Gitus executable: %s\n

    ", err.Error()) return false } } @@ -554,7 +554,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { fmt.Fprintf(w, "

    Failed to chown git root: %s\n

    ", err.Error()) return false } - ctx.Config.FilePath = path.Join(homePath, fmt.Sprintf("aegis-config-%d.json", time.Now().Unix())) + ctx.Config.FilePath = path.Join(homePath, fmt.Sprintf("gitus-config-%d.json", time.Now().Unix())) fmt.Fprint(w, "

    Git user setup done.

    ") ctx.Config.RecalculateProperPath() err = ctx.Config.Sync() @@ -570,7 +570,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { }() { goto leave } if !func()bool{ - if ctx.Config.OperationMode != aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode != gitus.OP_MODE_NORMAL { return true } fmt.Fprint(w, "

    Initializing database...

    ") @@ -598,7 +598,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { }() { goto leave } if !func()bool{ - if ctx.Config.OperationMode != aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode != gitus.OP_MODE_NORMAL { return true } fmt.Fprint(w, "

    Initializing session store...

    ") @@ -625,7 +625,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { }() { goto leave } if !func()bool{ - if ctx.Config.OperationMode != aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode != gitus.OP_MODE_NORMAL { return true } w.Write([]byte("

    Initializing receipt system...

    ")) @@ -652,7 +652,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { }() { goto leave } if !func()bool{ - if ctx.Config.OperationMode != aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode != gitus.OP_MODE_NORMAL { return true } fmt.Fprint(w, "

    Setting up admin user.

    ") @@ -698,7 +698,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { return false } } - fmt.Fprintf(w, "

    Admin user set up properly.

    Username: admin\nPassword: %s

    Please copy the password above because we don't store the plaintext; but, in the case you forgot, you can always run the following command to reset the admin user's password:

    aegis -config %s reset-admin
    ", userPassword, ctx.Config.FilePath) + fmt.Fprintf(w, "

    Admin user set up properly.

    Username: admin\nPassword: %s

    Please copy the password above because we don't store the plaintext; but, in the case you forgot, you can always run the following command to reset the admin user's password:

    gitus -config %s reset-admin
    ", userPassword, ctx.Config.FilePath) return true }() { goto leave } @@ -744,12 +744,12 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { return true }() { goto leave } - if ctx.Config.OperationMode == aegis.OP_MODE_SIMPLE { + if ctx.Config.OperationMode == gitus.OP_MODE_SIMPLE { if !func()bool{ var nsName string var keyRepoRelPath, configRepoRelPath string if ctx.Config.UseNamespace { - nsName = "__aegis" + nsName = "__gitus" keyRepoRelPath = path.Join(nsName, "__keys") configRepoRelPath = path.Join(nsName, "__repo_config") } else { @@ -780,7 +780,7 @@ func bindAllWebInstallerRoutes(ctx *WebInstallerRoutingContext) { fmt.Fprintf(w, "

    Failed to obtain key repository ownership for setting it up: %s

    ", err) return false } - _, err = model.AddFileToRepoString(keyRepo, "master", "admin/ssh/master_key", "Aegis Web Installer", "aegis@web.installer", "Aegis Web Installer", "aegis@web.installer", "init", ctx.RootSSHKey) + _, err = model.AddFileToRepoString(keyRepo, "master", "admin/ssh/master_key", "Gitus Web Installer", "gitus@web.installer", "Gitus Web Installer", "gitus@web.installer", "init", ctx.RootSSHKey) if err != nil { fmt.Fprintf(w, "

    Failed to add root ssh key to key repository: %s

    ", err) return false @@ -887,7 +887,7 @@ esac # --- Finished exit 0 -`, path.Join(ctx.GitUserHome, "git-shell-commands", "aegis"), shellparse.Quote(configFullPath))) +`, path.Join(ctx.GitUserHome, "git-shell-commands", "gitus"), shellparse.Quote(configFullPath))) if err != nil { fmt.Fprintf(w, "

    Failed to setup git update hook for key repository: %s

    ", err) return false @@ -911,7 +911,7 @@ exit 0 return false } if ctx.Config.UseNamespace { - fileList["__aegis/config.json"] = `{ + fileList["__gitus/config.json"] = `{ "namespace": { "description": "", "visibility": "private" @@ -947,7 +947,7 @@ exit 0 } } ` - _, err = model.AddMultipleFileToRepoString(configRepo, "master", "Aegis Web Installer", "aegis@web.installer", "Aegis Web Installer", "aegis@web.installer", "init", fileList) + _, err = model.AddMultipleFileToRepoString(configRepo, "master", "Gitus Web Installer", "gitus@web.installer", "Gitus Web Installer", "gitus@web.installer", "init", fileList) if err != nil { fmt.Fprintf(w, "

    Failed to add commit to config repository: %s

    ", err) return false @@ -956,23 +956,23 @@ exit 0 err = configRepo.(*gitlib.LocalGitRepository).SaveHook("post-update", fmt.Sprintf(` #!/bin/sh -%s -config "%s" simple-mode aegis-sync "%s" -`, path.Join(ctx.GitUserHome, "git-shell-commands", "aegis"), +%s -config "%s" simple-mode gitus-sync "%s" +`, path.Join(ctx.GitUserHome, "git-shell-commands", "gitus"), shellparse.Quote(configFullPath), - shellparse.Quote(path.Join(model.GetLocalRepositoryLocalPath(configRepo), "aegis_sync")), + shellparse.Quote(path.Join(model.GetLocalRepositoryLocalPath(configRepo), "gitus_sync")), )) if err != nil { fmt.Fprintf(w, "

    Failed to setup git post-update hook for config repo: %s

    ", err) return false } - // setting up aegis_sync. for the reason why - // aegis_sync exists, see docs/simple-mode.org. - cmd := exec.Command("git", "clone", ".", "aegis_sync") + // setting up gitus_sync. for the reason why + // gitus_sync exists, see docs/simple-mode.org. + cmd := exec.Command("git", "clone", ".", "gitus_sync") cmd.Dir = configRepoFullPath err = cmd.Run() if err != nil { - fmt.Fprintf(w, "

    Failed to setup aegis_sync: %s

    ", err) + fmt.Fprintf(w, "

    Failed to setup gitus_sync: %s

    ", err) return false } err = model.ChangeFileSystemOwnerByName(configRepo, ctx.Config.GitUser) @@ -982,7 +982,7 @@ exit 0 } if ctx.Config.UseNamespace { - err = auxfuncs.ChangeLocationOwnerByName(path.Join(ctx.Config.GitRoot, "__aegis"), ctx.Config.GitUser) + err = auxfuncs.ChangeLocationOwnerByName(path.Join(ctx.Config.GitRoot, "__gitus"), ctx.Config.GitUser) if err != nil { fmt.Fprintf(w, "

    Failed to return the namespace to configured git user: %s

    ", err) return false @@ -991,7 +991,7 @@ exit 0 // setting up authorized_keys file authorizedKeysPath := path.Join(ctx.GitUserHome, ".ssh", "authorized_keys") - keyEntry := fmt.Sprintf("command=\"aegis -config %s ssh admin master_key\" %s", shellparse.Quote(configFullPath), ctx.RootSSHKey) + keyEntry := fmt.Sprintf("command=\"gitus -config %s ssh admin master_key\" %s", shellparse.Quote(configFullPath), ctx.RootSSHKey) keyFile, err := os.OpenFile(authorizedKeysPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(w, "

    Failed to create authorized_keys file: %s

    ", err) @@ -1012,14 +1012,14 @@ exit 0 goto footer leave: - fmt.Fprintf(w, "

    The installation process failed but the config file might've been saved successfully at %s. In this case, you need to run the following command:

    aegis -config %s

    ", ctx.Config.FilePath, ctx.Config.FilePath) + fmt.Fprintf(w, "

    The installation process failed but the config file might've been saved successfully at %s. In this case, you need to run the following command:

    gitus -config %s

    ", ctx.Config.FilePath, ctx.Config.FilePath) footer: fmt.Fprint(w, `
    @@ -1035,7 +1035,7 @@ exit 0 } func WebInstaller() { - fmt.Println("This is the Aegis web installer. We will start a web server, which allows us to provide you a more user-friendly interface for configuring your Aegis instance. This web server will be shut down when the installation is finished. You can always start the web installer by using the `-init` flag or the `install` command.") + fmt.Println("This is the Gitus web installer. We will start a web server, which allows us to provide you a more user-friendly interface for configuring your Gitus instance. This web server will be shut down when the installation is finished. You can always start the web installer by using the `-init` flag or the `install` command.") var portNum int = 0 for { r, err := askString("Please enter the port number this web server would bind to.", "8001") @@ -1057,7 +1057,7 @@ func WebInstaller() { } bindAllWebInstallerRoutes(&WebInstallerRoutingContext{ Template: masterTemplate, - Config: &aegis.AegisConfig{}, + Config: &gitus.GitusConfig{}, }) go func() { log.Printf("Trying to serve at %s:%d\n", "0.0.0.0", portNum) diff --git a/devtools/generate-footer-template.go b/devtools/generate-footer-template.go index 8365fbb..a387e6a 100644 --- a/devtools/generate-footer-template.go +++ b/devtools/generate-footer-template.go @@ -35,7 +35,7 @@ func main() { f.WriteString(fmt.Sprintf(` {{define "_footer"}} {{end}}`, string(versionBytes), newVersionStr)) f.Close() diff --git a/go.mod b/go.mod index dc0a609..a0493af 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/bctnry/aegis +module github.com/GitusCodeForge/Gitus go 1.24.1 diff --git a/pkg/aegis/db/init/main.go b/pkg/aegis/db/init/main.go deleted file mode 100644 index c66c983..0000000 --- a/pkg/aegis/db/init/main.go +++ /dev/null @@ -1,18 +0,0 @@ -package init - -import ( - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/db/postgres" - "github.com/bctnry/aegis/pkg/aegis/db/sqlite" -) - - -func InitializeDatabase(cfg *aegis.AegisConfig) (db.AegisDatabaseInterface, error) { - switch cfg.Database.Type { - case "sqlite": return sqlite.NewSqliteAegisDatabaseInterface(cfg) - case "postgres": return postgres.NewPostgresAegisDatabaseInterface(cfg) - } - return nil, db.ErrDatabaseNotSupported -} - diff --git a/pkg/aegis/mail/mailif.go b/pkg/aegis/mail/mailif.go deleted file mode 100644 index 8cfb368..0000000 --- a/pkg/aegis/mail/mailif.go +++ /dev/null @@ -1,32 +0,0 @@ -package mail - -import ( - "errors" - - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/mail/gmail_plain" - "github.com/bctnry/aegis/pkg/aegis/mail/smtp_plain" -) - -type AegisMailerInterface interface { - SendPlainTextMail(target string, title string, body string) error - SendHTMLMail(target string, title string, body string) error -} - -var ErrNotSupported = errors.New("Type not supported.") - -func InitializeMailer(cfg *aegis.AegisConfig) (AegisMailerInterface, error) { - return CreateMailerFromMailerConfig(&cfg.Mailer) -} - -func CreateMailerFromMailerConfig(cfg *aegis.AegisMailerConfig) (AegisMailerInterface, error) { - switch cfg.Type { - case "gmail-plain": - return gmail_plain.NewAegisGmailPlainMailerInterface(cfg.User, cfg.Password) - case "smtp": - return smtp_plain.NewAegisSMTPPlainMailerInterface(cfg.SMTPServer, cfg.SMTPPort, cfg.SMTPAuth, cfg.User, cfg.Password) - } - return nil, ErrNotSupported -} - - diff --git a/pkg/aegis/receipt/init/main.go b/pkg/aegis/receipt/init/main.go deleted file mode 100644 index 4fbecf2..0000000 --- a/pkg/aegis/receipt/init/main.go +++ /dev/null @@ -1,17 +0,0 @@ -package init - -import ( - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/receipt" - "github.com/bctnry/aegis/pkg/aegis/receipt/sqlite" - "github.com/bctnry/aegis/pkg/aegis/receipt/postgres" -) - -func InitializeReceiptSystem(cfg *aegis.AegisConfig) (receipt.AegisReceiptSystemInterface, error) { - switch cfg.ReceiptSystem.Type { - case "sqlite": return sqlite.NewSqliteReceiptSystemInterface(cfg) - case "postgres": return postgres.NewPostgresReceiptSystemInterface(cfg) - } - return nil, receipt.ErrUnsupportedSystemType -} - diff --git a/pkg/aegis/session/init/main.go b/pkg/aegis/session/init/main.go deleted file mode 100644 index 11a57ed..0000000 --- a/pkg/aegis/session/init/main.go +++ /dev/null @@ -1,28 +0,0 @@ -package init - -import ( - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/session" - "github.com/bctnry/aegis/pkg/aegis/session/in_memory" - "github.com/bctnry/aegis/pkg/aegis/session/memcached" - "github.com/bctnry/aegis/pkg/aegis/session/redis_like" - "github.com/bctnry/aegis/pkg/aegis/session/sqlite" -) - - -func InitializeDatabase(cfg *aegis.AegisConfig) (session.AegisSessionStore, error) { - switch cfg.Session.Type { - case "sqlite": return sqlite.NewAegisSqliteSessionStore(cfg) - case "valkey": fallthrough - case "keydb": fallthrough - case "redis": - return redis_like.NewAegisRedisLikeSessionStore(cfg) - case "memcached": - return memcached.NewAegisMemcachedSessionStore(cfg) - case "in_memory": - return in_memory.NewAegisInMemorySessionStore(cfg) - } - return nil, db.ErrDatabaseNotSupported -} - diff --git a/pkg/gitlib/repository.go b/pkg/gitlib/repository.go index 8ee1e57..640d86e 100644 --- a/pkg/gitlib/repository.go +++ b/pkg/gitlib/repository.go @@ -12,7 +12,7 @@ import ( "path" "strings" - "github.com/bctnry/aegis/pkg/ini" + "github.com/GitusCodeForge/Gitus/pkg/ini" ) type LocalGitRepository struct { diff --git a/pkg/gitlib/submodule.go b/pkg/gitlib/submodule.go index 7176eae..0349e15 100644 --- a/pkg/gitlib/submodule.go +++ b/pkg/gitlib/submodule.go @@ -5,7 +5,7 @@ import ( "os" "path" - "github.com/bctnry/aegis/pkg/ini" + "github.com/GitusCodeForge/Gitus/pkg/ini" ) type SubmoduleConfig struct { diff --git a/pkg/aegis/config.go b/pkg/gitus/config.go similarity index 87% rename from pkg/aegis/config.go rename to pkg/gitus/config.go index 1f3a185..f9a2278 100644 --- a/pkg/aegis/config.go +++ b/pkg/gitus/config.go @@ -1,4 +1,4 @@ -package aegis +package gitus import ( "encoding/json" @@ -11,11 +11,11 @@ import ( "strings" "sync" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" ) -type AegisConfig struct { +type GitusConfig struct { lock sync.RWMutex FilePath string // the version of the configuration file. currently only 0 is @@ -75,7 +75,7 @@ type AegisConfig struct { // git-related config. // NOTE(2025.12.30): we'll gradually move certain config options into here. - GitConfig AegisGitConfig `json:"gitConfig"` + GitConfig GitusGitConfig `json:"gitConfig"` // cosmetic things... @@ -119,13 +119,13 @@ type AegisConfig struct { // the following database-related options are ignored when plain // mode is enabled, - Database AegisDatabaseConfig `json:"database"` - Session AegisSessionConfig `json:"session"` - Mailer AegisMailerConfig `json:"mailer"` - ReceiptSystem AegisReceiptSystemConfig `json:"receiptSystem"` + Database GitusDatabaseConfig `json:"database"` + Session GitusSessionConfig `json:"session"` + Mailer GitusMailerConfig `json:"mailer"` + ReceiptSystem GitusReceiptSystemConfig `json:"receiptSystem"` // what should the instance display when the front page is visited. - FrontPage AegisFrontPageConfig `json:"frontPage"` + FrontPage GitusFrontPageConfig `json:"frontPage"` // global private/shutdown mode // supports the following values: @@ -151,18 +151,18 @@ type AegisConfig struct { // confirm code manager. // used in email 2fa. - ConfirmCodeManager AegisConfirmCodeManagerConfig `json:"confirmCode"` + ConfirmCodeManager GitusConfirmCodeManagerConfig `json:"confirmCode"` // root directory for storing snippets. SnippetRoot string `json:"snippetRoot"` - DefaultNewUserStatus model.AegisUserStatus `json:"defaultNewUserStatus"` + DefaultNewUserStatus model.GitusUserStatus `json:"defaultNewUserStatus"` DefaultNewUserNamespace string `json:"defaultNewUserNamespace"` // theme. // currently it's just a foreground color & a background color but there // could be more in the future. - Theme AegisThemeConfig `json:"theme"` + Theme GitusThemeConfig `json:"theme"` } @@ -173,7 +173,7 @@ const ( GLOBAL_VISIBILITY_MAINTENANCE = "maintenance" ) -type AegisDatabaseConfig struct { +type GitusDatabaseConfig struct { // database type. currently only support "sqlite". Type string `json:"type"` // path to the database file. valid only when dbtype is sqlite; @@ -200,16 +200,16 @@ type AegisDatabaseConfig struct { TablePrefix string `json:"tablePrefix"` } -type AegisGitHTTPTransferProtocolDescriptor struct { +type GitusGitHTTPTransferProtocolDescriptor struct { // true if enabled. V1Dumb bool `json:"v1dumb"` V2 bool `json:"v2"` } -type AegisGitConfig struct { - HTTPCloneProtocol AegisGitHTTPTransferProtocolDescriptor `json:"httpCloneProtocol"` +type GitusGitConfig struct { + HTTPCloneProtocol GitusGitHTTPTransferProtocolDescriptor `json:"httpCloneProtocol"` } -type AegisSessionConfig struct { +type GitusSessionConfig struct { // session type. currently only support: // + "sqlite" // + redis-like dbs: "redis", "keydb", "valkey" @@ -241,7 +241,7 @@ type AegisSessionConfig struct { DatabaseNumber int `json:"databaseNumber"` } -type AegisMailerConfig struct { +type GitusMailerConfig struct { // email sender type. currently "gmail-plain" and "smtp" are supported. Type string `json:"type"` // smtp server & smtp port. technically not used if type is gmail-plain. @@ -255,10 +255,10 @@ type AegisMailerConfig struct { Password string `json:"password"` } -// NOTE: this is the same as AegisDatabaseConfig - i suspect that people +// NOTE: this is the same as GitusDatabaseConfig - i suspect that people // would want to be able to search & filter specific kind of receipts and // i couldn't figure out a good way to implement that w/ redis. -type AegisReceiptSystemConfig struct { +type GitusReceiptSystemConfig struct { // database type. currently only support "sqlite". Type string `json:"type"` // path to the database file. valid only when dbtype is sqlite; @@ -285,13 +285,13 @@ type AegisReceiptSystemConfig struct { TablePrefix string `json:"tablePrefix"` } -type AegisConfirmCodeManagerConfig struct { +type GitusConfirmCodeManagerConfig struct { // type. currently only supports "in-memory". Type string `json:"type"` DefaultTimeoutMinute int `json:"defaultTimeoutMinute"` } -type AegisFrontPageConfig struct { +type GitusFrontPageConfig struct { // + "all/namespace" // + "all/repository" // + "repository" @@ -311,46 +311,46 @@ type AegisFrontPageConfig struct { FileContent string `json:"fileContent"` } -type AegisThemeConfig struct { +type GitusThemeConfig struct { ForegroundColor string `json:"foregroundColor"` BackgroundColor string `json:"backgroundColor"` } // proper http host name. no trailing slash. -func (cfg *AegisConfig) ProperHTTPHostName() string { +func (cfg *GitusConfig) ProperHTTPHostName() string { // proper http host name. no trailing slash. return cfg.properHttpHostName } -func (cfg *AegisConfig) ProperSSHHostName() string { +func (cfg *GitusConfig) ProperSSHHostName() string { return cfg.properSshHostName } -func (cfg *AegisConfig) ProperDatabasePath() string { +func (cfg *GitusConfig) ProperDatabasePath() string { return cfg.Database.properPath } -func (cfg *AegisConfig) ProperSessionPath() string { +func (cfg *GitusConfig) ProperSessionPath() string { return cfg.Session.properPath } -func (cfg *AegisConfig) ProperReceiptSystemPath() string { +func (cfg *GitusConfig) ProperReceiptSystemPath() string { return cfg.ReceiptSystem.properPath } -func (cfg *AegisConfig) GitSSHHostName() string { +func (cfg *GitusConfig) GitSSHHostName() string { return cfg.gitSshHostName } -func (cfg *AegisConfig) LockForSync() { +func (cfg *GitusConfig) LockForSync() { cfg.lock.Lock() } -func (cfg *AegisConfig) Unlock() { +func (cfg *GitusConfig) Unlock() { cfg.lock.Unlock() } -func (cfg *AegisConfig) GetRRDocTitle(p string) string { +func (cfg *GitusConfig) GetRRDocTitle(p string) string { for _, v := range cfg.ReadingRequiredDocument { if v.Path == p { return v.Title } } @@ -363,7 +363,7 @@ const ( OP_MODE_NORMAL = "normal" ) -func (cfg *AegisConfig) IsInPlainMode() bool { +func (cfg *GitusConfig) IsInPlainMode() bool { return cfg.OperationMode == OP_MODE_PLAIN } @@ -375,7 +375,7 @@ func CreateConfigFile(p string) error { ) if err != nil { return err } defer f.Close() - marshalRes, err := json.MarshalIndent(AegisConfig{ + marshalRes, err := json.MarshalIndent(GitusConfig{ Version: 0, GitRoot: "", GitUser: "git", @@ -384,7 +384,7 @@ func CreateConfigFile(p string) error { AllowRegistration: true, EmailConfirmationRequired: true, ManualApproval: true, - DepotName: "Aegis", + DepotName: "Gitus", StaticAssetDirectory: "static/", BindAddress: "127.0.0.1", BindPort: 8000, @@ -392,22 +392,22 @@ func CreateConfigFile(p string) error { IgnoreRepository: nil, GlobalVisibility: "public", FullAccessUser: []string{"admin"}, - GitConfig: AegisGitConfig{ - HTTPCloneProtocol: AegisGitHTTPTransferProtocolDescriptor{ + GitConfig: GitusGitConfig{ + HTTPCloneProtocol: GitusGitHTTPTransferProtocolDescriptor{ V1Dumb: true, V2: true, }, }, - Database: AegisDatabaseConfig{ + Database: GitusDatabaseConfig{ Type: "sqlite", Path: "", URL: "", UserName: "", DatabaseName: "", Password: "", - TablePrefix: "aegis", + TablePrefix: "gitus", }, - Session: AegisSessionConfig{ + Session: GitusSessionConfig{ Type: "sqlite", Path: "", TablePrefix: "", @@ -416,37 +416,37 @@ func CreateConfigFile(p string) error { Password: "", DatabaseNumber: 0, }, - Mailer: AegisMailerConfig{ + Mailer: GitusMailerConfig{ Type: "gmail-plain", SMTPServer: "", SMTPPort: 0, User: "", Password: "", }, - ReceiptSystem: AegisReceiptSystemConfig{ + ReceiptSystem: GitusReceiptSystemConfig{ Type: "sqlite", Path: "", URL: "", UserName: "", DatabaseName: "", Password: "", - TablePrefix: "aegis_receipt_", + TablePrefix: "gitus_receipt_", }, MaxRequestInSecond: 500, - ConfirmCodeManager: AegisConfirmCodeManagerConfig{ + ConfirmCodeManager: GitusConfirmCodeManagerConfig{ Type: "in-memory", DefaultTimeoutMinute: 5, }, SnippetRoot: "", - DefaultNewUserStatus: model.AegisUserStatus(model.NORMAL_USER), + DefaultNewUserStatus: model.GitusUserStatus(model.NORMAL_USER), DefaultNewUserNamespace: "", - FrontPage: AegisFrontPageConfig{ + FrontPage: GitusFrontPageConfig{ Type: "all/repository", Namespace: "", Repository: "", FileContent: "", }, - Theme: AegisThemeConfig{ + Theme: GitusThemeConfig{ ForegroundColor: "black", BackgroundColor: "white", }, @@ -456,7 +456,7 @@ func CreateConfigFile(p string) error { return nil } -func (c *AegisConfig) RecalculateProperPath() error { +func (c *GitusConfig) RecalculateProperPath() error { // fix http host name & ssh host name... c.properHttpHostName = c.HttpHostName if strings.TrimSpace(c.HttpHostName) != "" { @@ -537,10 +537,10 @@ func (c *AegisConfig) RecalculateProperPath() error { return nil } -func LoadConfigFile(p string) (*AegisConfig, error) { +func LoadConfigFile(p string) (*GitusConfig, error) { s, err := os.ReadFile(p) if err != nil { return nil, err } - var c AegisConfig + var c GitusConfig err = json.Unmarshal(s, &c) if err != nil { return nil, err } c.FilePath = p @@ -549,7 +549,7 @@ func LoadConfigFile(p string) (*AegisConfig, error) { return &c, nil } -func (cfg *AegisConfig) Sync() error { +func (cfg *GitusConfig) Sync() error { p := cfg.FilePath s, err := json.MarshalIndent(cfg, "", " ") if err != nil { return err } @@ -570,22 +570,22 @@ func (cfg *AegisConfig) Sync() error { return nil } -func (cfg *AegisConfig) ReadNamespaceSimpleModeConfig(name string) (*model.SimpleModeNamespaceConfig, error) { - f := path.Join(cfg.GitRoot, "__aegis", "__repo_config", "aegis_sync", name, "config.json") +func (cfg *GitusConfig) ReadNamespaceSimpleModeConfig(name string) (*model.SimpleModeNamespaceConfig, error) { + f := path.Join(cfg.GitRoot, "__gitus", "__repo_config", "gitus_sync", name, "config.json") return model.ReadNamespaceConfigFromFile(f) } -func (cfg *AegisConfig) ReadRepositorySimpleModeConfig(namespace string, name string) (*model.SimpleModeRepositoryConfig, error) { +func (cfg *GitusConfig) ReadRepositorySimpleModeConfig(namespace string, name string) (*model.SimpleModeRepositoryConfig, error) { var f string if cfg.UseNamespace { - f = path.Join(cfg.GitRoot, "__aegis", "__repo_config", "aegis_sync", namespace, name, "config.json") + f = path.Join(cfg.GitRoot, "__gitus", "__repo_config", "gitus_sync", namespace, name, "config.json") } else { - f = path.Join(cfg.GitRoot, "__repo_config", "aegis_sync", name, "config.json") + f = path.Join(cfg.GitRoot, "__repo_config", "gitus_sync", name, "config.json") } return model.ReadRepositoryConfigFromFile(f) } -func (cfg *AegisConfig) GetAllRepositoryPlain() ([]*model.Repository, error) { +func (cfg *GitusConfig) GetAllRepositoryPlain() ([]*model.Repository, error) { if cfg.UseNamespace { m, err := cfg.GetAllNamespacePlain() if err != nil { return nil, err } @@ -637,7 +637,7 @@ func (cfg *AegisConfig) GetAllRepositoryPlain() ([]*model.Repository, error) { return res, nil } -func (cfg *AegisConfig) GetAllRepositoryByNamespacePlain(ns string) (map[string]*model.Repository, error) { +func (cfg *GitusConfig) GetAllRepositoryByNamespacePlain(ns string) (map[string]*model.Repository, error) { gitPath := cfg.GitRoot res := make(map[string]*model.Repository, 0) nsPath := path.Join(gitPath, ns) @@ -678,7 +678,7 @@ func (cfg *AegisConfig) GetAllRepositoryByNamespacePlain(ns string) (map[string] return res, nil } -func (cfg *AegisConfig) GetAllNamespacePlain() (map[string]*model.Namespace, error) { +func (cfg *GitusConfig) GetAllNamespacePlain() (map[string]*model.Namespace, error) { res := make(map[string]*model.Namespace, 0) if !cfg.UseNamespace { ns, err := model.NewNamespace("", cfg.GitRoot) @@ -731,7 +731,7 @@ func (cfg *AegisConfig) GetAllNamespacePlain() (map[string]*model.Namespace, err } // TODO: find a better & more efficient way to do this. -func (cfg *AegisConfig) SearchAllNamespacePlain(pattern string) (map[string]*model.Namespace, error) { +func (cfg *GitusConfig) SearchAllNamespacePlain(pattern string) (map[string]*model.Namespace, error) { preres, err := cfg.GetAllNamespacePlain() if err != nil { return nil, err } res := make(map[string]*model.Namespace, 0) @@ -743,7 +743,7 @@ func (cfg *AegisConfig) SearchAllNamespacePlain(pattern string) (map[string]*mod return res, nil } -func (cfg *AegisConfig) SearchAllRepositoryPlain(pattern string) ([]*model.Repository, error) { +func (cfg *GitusConfig) SearchAllRepositoryPlain(pattern string) ([]*model.Repository, error) { preres, err := cfg.GetAllRepositoryPlain() if err != nil { return nil, err } res := make([]*model.Repository, 0) diff --git a/pkg/aegis/confirm_code/dbif.go b/pkg/gitus/confirm_code/dbif.go similarity index 72% rename from pkg/aegis/confirm_code/dbif.go rename to pkg/gitus/confirm_code/dbif.go index b69b154..a18a23f 100644 --- a/pkg/aegis/confirm_code/dbif.go +++ b/pkg/gitus/confirm_code/dbif.go @@ -4,21 +4,21 @@ import ( "errors" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/tcache" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/tcache" ) // temporary cache. // used to store kv pairs that expires after a set amount of time. -type AegisConfirmCodeManager interface { +type GitusConfirmCodeManager interface { Register(key string, value string, d time.Duration) Get(key string) (string, bool) } var ErrNotSupported = errors.New("Not supported") -func InitializeConfirmCodeManager(cfg *aegis.AegisConfig) (AegisConfirmCodeManager, error) { +func InitializeConfirmCodeManager(cfg *gitus.GitusConfig) (GitusConfirmCodeManager, error) { switch cfg.ConfirmCodeManager.Type { case "in-memory": return tcache.NewTCache(time.Duration(cfg.ConfirmCodeManager.DefaultTimeoutMinute * int(time.Minute))), nil diff --git a/pkg/aegis/db/aux.go b/pkg/gitus/db/aux.go similarity index 100% rename from pkg/aegis/db/aux.go rename to pkg/gitus/db/aux.go diff --git a/pkg/aegis/db/dberr.go b/pkg/gitus/db/dberr.go similarity index 100% rename from pkg/aegis/db/dberr.go rename to pkg/gitus/db/dberr.go diff --git a/pkg/aegis/db/dbif.go b/pkg/gitus/db/dbif.go similarity index 92% rename from pkg/aegis/db/dbif.go rename to pkg/gitus/db/dbif.go index e28dc20..b58d0ec 100644 --- a/pkg/aegis/db/dbif.go +++ b/pkg/gitus/db/dbif.go @@ -1,24 +1,24 @@ package db import ( - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" ) -type AegisDatabaseInterface interface { +type GitusDatabaseInterface interface { // we have to discern between "database unusable" and "error while detecting". IsDatabaseUsable() (bool, error) InstallTables() error Dispose() error - GetUserByName(name string) (*model.AegisUser, error) - GetAllAuthKeyByUsername(name string) ([]model.AegisAuthKey, error) - GetAuthKeyByName(userName string, keyName string) (*model.AegisAuthKey, error) + GetUserByName(name string) (*model.GitusUser, error) + GetAllAuthKeyByUsername(name string) ([]model.GitusAuthKey, error) + GetAuthKeyByName(userName string, keyName string) (*model.GitusAuthKey, error) RegisterAuthKey(username string, keyname string, keytext string) error UpdateAuthKey(username string, keyname string, keytext string) error RemoveAuthKey(username string, keyname string) error - GetAllSignKeyByUsername(name string) ([]model.AegisSigningKey, error) - GetSignKeyByName(userName string, keyName string) (*model.AegisSigningKey, error) + GetAllSignKeyByUsername(name string) ([]model.GitusSigningKey, error) + GetSignKeyByName(userName string, keyName string) (*model.GitusSigningKey, error) UpdateSignKey(username string, keyname string, keytext string) error RegisterSignKey(username string, keyname string, keytext string) error RemoveSignKey(username string, keyname string) error @@ -33,20 +33,20 @@ type AegisDatabaseInterface interface { GetAllNamespaceByOwner(name string) (map[string]*model.Namespace, error) GetAllRepositoryFromNamespace(name string) (map[string]*model.Repository, error) GetAllVisibleRepositoryFromNamespace(username string, ns string) ([]*model.Repository, error) - RegisterUser(name string, email string, passwordHash string, status model.AegisUserStatus) (*model.AegisUser, error) + RegisterUser(name string, email string, passwordHash string, status model.GitusUserStatus) (*model.GitusUser, error) // update user info. NOTE THAT any implementers MUST update the // status field as well if that has changed. - UpdateUserInfo(name string, uobj *model.AegisUser) error + UpdateUserInfo(name string, uobj *model.GitusUser) error UpdateUserPassword(name string, newPasswordHash string) error // soft delete vs. hard delete: // "soft delete" mark the user as deleted. // "hard delete" removes the data from the database for good. HardDeleteUserByName(name string) error - UpdateUserStatus(name string, newStatus model.AegisUserStatus) error + UpdateUserStatus(name string, newStatus model.GitusUserStatus) error RegisterNamespace(name string, ownerUsername string) (*model.Namespace, error) UpdateNamespaceInfo(name string, nsobj *model.Namespace) error UpdateNamespaceOwner(name string, newOwner string) error - UpdateNamespaceStatus(name string, newStatus model.AegisNamespaceStatus) error + UpdateNamespaceStatus(name string, newStatus model.GitusNamespaceStatus) error // the implementer should remove the directory as well. HardDeleteNamespaceByName(name string) error // the implementer should create the git directory as well. common @@ -55,13 +55,13 @@ type AegisDatabaseInterface interface { // same as `CreateRepository` but with related fields being set. SetUpCloneRepository(originNs string, originName string, targetNs string, targetName string, owner string) (*model.Repository, error) UpdateRepositoryInfo(ns string, name string, robj *model.Repository) error - UpdateRepositoryStatus(ns string, name string, status model.AegisRepositoryStatus) error + UpdateRepositoryStatus(ns string, name string, status model.GitusRepositoryStatus) error HardDeleteRepository(ns string, name string) error - // TODO: aegis currently doesn't support moving. + // TODO: gitus currently doesn't support moving. // we'll reconsider this when the appropriate time comes. // MoveRepository(oldNs string, oldName string, newNs string, newName string) error - GetAllUsers(pageNum int64, pageSize int64) ([]*model.AegisUser, error) + GetAllUsers(pageNum int64, pageSize int64) ([]*model.GitusUser, error) GetAllNamespaces(pageNum int64, pageSize int64) (map[string]*model.Namespace, error) GetAllRepositories(pageNum int64, pageSize int64) ([]*model.Repository, error) @@ -74,7 +74,7 @@ type AegisDatabaseInterface interface { // search user name & title containing the string `k`, case // insensitive. - SearchForUser(k string, pageNum int64, pageSize int64) ([]*model.AegisUser, error) + SearchForUser(k string, pageNum int64, pageSize int64) ([]*model.GitusUser, error) // search namespce name & title containing the string `k`, case // insensitive. diff --git a/pkg/gitus/db/init/main.go b/pkg/gitus/db/init/main.go new file mode 100644 index 0000000..459dd70 --- /dev/null +++ b/pkg/gitus/db/init/main.go @@ -0,0 +1,18 @@ +package init + +import ( + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db/postgres" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db/sqlite" +) + + +func InitializeDatabase(cfg *gitus.GitusConfig) (db.GitusDatabaseInterface, error) { + switch cfg.Database.Type { + case "sqlite": return sqlite.NewSqliteGitusDatabaseInterface(cfg) + case "postgres": return postgres.NewPostgresGitusDatabaseInterface(cfg) + } + return nil, db.ErrDatabaseNotSupported +} + diff --git a/pkg/aegis/db/postgres/defs.go b/pkg/gitus/db/postgres/defs.go similarity index 75% rename from pkg/aegis/db/postgres/defs.go rename to pkg/gitus/db/postgres/defs.go index e41ee04..8990e6b 100644 --- a/pkg/aegis/db/postgres/defs.go +++ b/pkg/gitus/db/postgres/defs.go @@ -6,18 +6,18 @@ import ( "fmt" "net/url" - "github.com/bctnry/aegis/pkg/aegis" + "github.com/GitusCodeForge/Gitus/pkg/gitus" "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" ) -type PostgresAegisDatabaseInterface struct { - config *aegis.AegisConfig +type PostgresGitusDatabaseInterface struct { + config *gitus.GitusConfig pool *pgxpool.Pool } -func NewPostgresAegisDatabaseInterface(cfg *aegis.AegisConfig) (*PostgresAegisDatabaseInterface, error) { +func NewPostgresGitusDatabaseInterface(cfg *gitus.GitusConfig) (*PostgresGitusDatabaseInterface, error) { u := &url.URL{ Scheme: "postgres", User: url.UserPassword(cfg.Database.UserName, cfg.Database.Password), @@ -26,13 +26,13 @@ func NewPostgresAegisDatabaseInterface(cfg *aegis.AegisConfig) (*PostgresAegisDa } pool, err := pgxpool.New(context.TODO(), u.String()) if err != nil { return nil, err } - return &PostgresAegisDatabaseInterface{ + return &PostgresGitusDatabaseInterface{ config: cfg, pool: pool, }, nil } -func (dbif *PostgresAegisDatabaseInterface) Dispose() error { +func (dbif *PostgresGitusDatabaseInterface) Dispose() error { dbif.pool.Close() return nil } @@ -51,7 +51,7 @@ var requiredTableList = []string{ "webhook_log", } -func (dbif *PostgresAegisDatabaseInterface) IsDatabaseUsable() (bool, error) { +func (dbif *PostgresGitusDatabaseInterface) IsDatabaseUsable() (bool, error) { ctx := context.Background() queryStr := ` SELECT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = $1) diff --git a/pkg/aegis/db/postgres/install.go b/pkg/gitus/db/postgres/install.go similarity index 98% rename from pkg/aegis/db/postgres/install.go rename to pkg/gitus/db/postgres/install.go index 98d5449..248977c 100644 --- a/pkg/aegis/db/postgres/install.go +++ b/pkg/gitus/db/postgres/install.go @@ -15,7 +15,7 @@ import ( // complex (e.g. ACLs): JSONB // integer enum: SMALLINT -func (dbif *PostgresAegisDatabaseInterface) InstallTables() error { +func (dbif *PostgresGitusDatabaseInterface) InstallTables() error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) diff --git a/pkg/aegis/db/postgres/query.go b/pkg/gitus/db/postgres/query.go similarity index 91% rename from pkg/aegis/db/postgres/query.go rename to pkg/gitus/db/postgres/query.go index c7fed68..9860228 100644 --- a/pkg/aegis/db/postgres/query.go +++ b/pkg/gitus/db/postgres/query.go @@ -14,13 +14,13 @@ import ( "strings" "time" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" "github.com/jackc/pgx/v5" ) -func (dbif *PostgresAegisDatabaseInterface) GetUserByName(name string) (*model.AegisUser, error) { +func (dbif *PostgresGitusDatabaseInterface) GetUserByName(name string) (*model.GitusUser, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -29,14 +29,14 @@ FROM %s_user WHERE user_name = $1 `, pfx), name) var title, email, bio, website, password string - var tfa model.AegisUser2FAConfig - var wPref model.AegisUserWebsitePreference + var tfa model.GitusUser2FAConfig + var wPref model.GitusUserWebsitePreference var datetime time.Time var status int err := stmt.Scan(&title, &email, &bio, &website, &datetime, &password, &status, &tfa, &wPref) if errors.Is(err, pgx.ErrNoRows) { return nil, db.ErrEntityNotFound } if err != nil { return nil, err } - return &model.AegisUser{ + return &model.GitusUser{ Name: name, Title: title, Email: email, @@ -44,13 +44,13 @@ WHERE user_name = $1 Website: website, PasswordHash: password, RegisterTime: datetime.Unix(), - Status: model.AegisUserStatus(status), + Status: model.GitusUserStatus(status), TFAConfig: tfa, WebsitePreference: wPref, }, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllAuthKeyByUsername(name string) ([]model.AegisAuthKey, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllAuthKeyByUsername(name string) ([]model.GitusAuthKey, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -60,12 +60,12 @@ WHERE user_name = $1 `, pfx), name) if err != nil { return nil, err } defer stmt.Close() - res := make([]model.AegisAuthKey, 0) + res := make([]model.GitusAuthKey, 0) for stmt.Next() { var kname, ktext string err := stmt.Scan(&kname, &ktext) if err != nil { return nil, err } - res = append(res, model.AegisAuthKey{ + res = append(res, model.GitusAuthKey{ UserName: name, KeyName: kname, KeyText: ktext, @@ -74,7 +74,7 @@ WHERE user_name = $1 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAuthKeyByName(userName string, keyName string) (*model.AegisAuthKey, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAuthKeyByName(userName string, keyName string) (*model.GitusAuthKey, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -84,14 +84,14 @@ SELECT key_text FROM %s_user_authkey WHERE user_name = $1 AND key_name = $2 err := stmt.Scan(&ktext) if errors.Is(err, pgx.ErrNoRows) { return nil, db.ErrEntityNotFound } if err != nil { return nil, err } - return &model.AegisAuthKey{ + return &model.GitusAuthKey{ UserName: userName, KeyName: keyName, KeyText: ktext, }, nil } -func (dbif *PostgresAegisDatabaseInterface) RegisterAuthKey(username string, keyname string, keytext string) error { +func (dbif *PostgresGitusDatabaseInterface) RegisterAuthKey(username string, keyname string, keytext string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -107,7 +107,7 @@ VALUES ($1, $2, $3) return nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateAuthKey(username string, keyname string, keytext string) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateAuthKey(username string, keyname string, keytext string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -124,7 +124,7 @@ WHERE user_name = $2 AND key_name = $3 return nil } -func (dbif *PostgresAegisDatabaseInterface) RemoveAuthKey(username string, keyname string) error { +func (dbif *PostgresGitusDatabaseInterface) RemoveAuthKey(username string, keyname string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -140,7 +140,7 @@ WHERE user_name = $1 AND key_name = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllSignKeyByUsername(name string) ([]model.AegisSigningKey, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllSignKeyByUsername(name string) ([]model.GitusSigningKey, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -148,12 +148,12 @@ SELECT key_name, key_text FROM %s_user_signkey WHERE user_name = $1 `, pfx), name) if err != nil { return nil, err } defer stmt.Close() - res := make([]model.AegisSigningKey, 0) + res := make([]model.GitusSigningKey, 0) for stmt.Next() { var kname, ktext string err := stmt.Scan(&kname, &ktext) if err != nil { return nil, err } - res = append(res, model.AegisSigningKey{ + res = append(res, model.GitusSigningKey{ UserName: name, KeyName: kname, KeyText: ktext, @@ -162,7 +162,7 @@ SELECT key_name, key_text FROM %s_user_signkey WHERE user_name = $1 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetSignKeyByName(userName string, keyName string) (*model.AegisSigningKey, error) { +func (dbif *PostgresGitusDatabaseInterface) GetSignKeyByName(userName string, keyName string) (*model.GitusSigningKey, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -172,14 +172,14 @@ SELECT key_text FROM %s_user_signkey WHERE user_name = $1 AND key_name = $2 err := stmt.Scan(&ktext) if errors.Is(err, pgx.ErrNoRows) { return nil, db.ErrEntityNotFound } if err != nil { return nil, err } - return &model.AegisSigningKey{ + return &model.GitusSigningKey{ UserName: userName, KeyName: keyName, KeyText: ktext, }, nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateSignKey(username string, keyname string, keytext string) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateSignKey(username string, keyname string, keytext string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -196,7 +196,7 @@ WHERE user_name = $2 AND key_name = $3 return nil } -func (dbif *PostgresAegisDatabaseInterface) RegisterSignKey(username string, keyname string, keytext string) error { +func (dbif *PostgresGitusDatabaseInterface) RegisterSignKey(username string, keyname string, keytext string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -212,7 +212,7 @@ VALUES ($1, $2, $3) return nil } -func (dbif *PostgresAegisDatabaseInterface) RemoveSignKey(username string, keyname string) error { +func (dbif *PostgresGitusDatabaseInterface) RemoveSignKey(username string, keyname string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -228,7 +228,7 @@ WHERE user_name = $1 AND key_name = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) GetNamespaceByName(name string) (*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) GetNamespaceByName(name string) (*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -251,12 +251,12 @@ WHERE ns_name = $1 Email: email, Owner: owner, RegisterTime: datetime.Unix(), - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), ACL: a, }, nil } -func (dbif *PostgresAegisDatabaseInterface) GetRepositoryByName(nsName string, repoName string) (*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) GetRepositoryByName(nsName string, repoName string) (*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -279,7 +279,7 @@ WHERE repo_namespace = $1 AND repo_name = $2 res.AbsId = rowid res.Type = uint8(repoType) res.Owner = owner - res.Status = model.AegisRepositoryStatus(repoStatus) + res.Status = model.GitusRepositoryStatus(repoStatus) res.ForkOriginNamespace = forkOriginNamespace res.ForkOriginName = forkOriginName var tags []string = nil @@ -296,7 +296,7 @@ WHERE repo_namespace = $1 AND repo_name = $2 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllNamespace() (map[string]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllNamespace() (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -322,13 +322,13 @@ FROM %s_namespace Owner: owner, RegisterTime: datetime.Unix(), ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllVisibleNamespace(username string) (map[string]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllVisibleNamespace(username string) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -355,13 +355,13 @@ WHERE ns_owner = $1 OR ns_acl->'ACL' ? $2 Owner: owner, RegisterTime: datetime.Unix(), ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllVisibleNamespacePaginated(username string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllVisibleNamespacePaginated(username string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -400,13 +400,13 @@ ORDER BY ns_absid ASC LIMIT $1 OFFSET $2 Owner: owner, RegisterTime: datetime.Unix(), ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) SearchAllVisibleNamespacePaginated(username string, query string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) SearchAllVisibleNamespacePaginated(username string, query string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -463,14 +463,14 @@ ORDER BY ns_absid ASC LIMIT $1 OFFSET $2 Owner: owner, RegisterTime: datetime.Unix(), ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllVisibleRepositoryPaginated(username string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllVisibleRepositoryPaginated(username string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -514,7 +514,7 @@ ORDER BY repo_absid ASC LIMIT $1 OFFSET $2 Description: description, Owner: owner, AccessControlList: a, - Status: model.AegisRepositoryStatus(rStatus), + Status: model.GitusRepositoryStatus(rStatus), Type: uint8(rType), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -525,7 +525,7 @@ ORDER BY repo_absid ASC LIMIT $1 OFFSET $2 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) SearchAllVisibleRepositoryPaginated(username string, query string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) SearchAllVisibleRepositoryPaginated(username string, query string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -587,7 +587,7 @@ ORDER BY repo_absid ASC LIMIT $1 OFFSET $2 Description: description, Owner: owner, AccessControlList: a, - Status: model.AegisRepositoryStatus(rStatus), + Status: model.GitusRepositoryStatus(rStatus), Type: uint8(rType), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -598,7 +598,7 @@ ORDER BY repo_absid ASC LIMIT $1 OFFSET $2 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllNamespaceByOwner(name string) (map[string]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllNamespaceByOwner(name string) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -625,13 +625,13 @@ WHERE ns_owner = $1 Owner: owner, RegisterTime: regtime.Unix(), ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllRepositoryFromNamespace(name string) (map[string]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllRepositoryFromNamespace(name string) (map[string]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -665,7 +665,7 @@ WHERE repo_namespace = $1 Description: desc, Owner: owner, AccessControlList: a, - Status: model.AegisRepositoryStatus(rStatus), + Status: model.GitusRepositoryStatus(rStatus), Type: uint8(rType), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -677,7 +677,7 @@ WHERE repo_namespace = $1 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllVisibleRepositoryFromNamespace(username string, ns string) ([]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllVisibleRepositoryFromNamespace(username string, ns string) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -722,7 +722,7 @@ WHERE repo_namespace = $1 AND (repo_status = 1 OR repo_owner = $2 OR repo_acl->' Description: desc, Owner: owner, AccessControlList: a, - Status: model.AegisRepositoryStatus(rStatus), + Status: model.GitusRepositoryStatus(rStatus), Type: uint8(rType), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -734,23 +734,23 @@ WHERE repo_namespace = $1 AND (repo_status = 1 OR repo_owner = $2 OR repo_acl->' return res, nil } -func (dbif *PostgresAegisDatabaseInterface) RegisterUser(name string, email string, passwordHash string, status model.AegisUserStatus) (*model.AegisUser, error) { +func (dbif *PostgresGitusDatabaseInterface) RegisterUser(name string, email string, passwordHash string, status model.GitusUserStatus) (*model.GitusUser, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) if err != nil { return nil, err } defer tx.Rollback(ctx) t := time.Now() - webp := new(model.AegisUserWebsitePreference) + webp := new(model.GitusUserWebsitePreference) webp.UseSiteWideThemeConfig = true _, err = tx.Exec(ctx, fmt.Sprintf(` INSERT INTO %s_user(user_name, user_title, user_email, user_bio, user_website, user_reg_datetime, user_password_hash, user_status, user_2fa_config, user_website_preference) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) -`, pfx), name, name, email, new(string), new(string), t, passwordHash, status, new(model.AegisUser2FAConfig), webp) +`, pfx), name, name, email, new(string), new(string), t, passwordHash, status, new(model.GitusUser2FAConfig), webp) if err != nil { return nil, err } err = tx.Commit(ctx) if err != nil { return nil, err } - return &model.AegisUser{ + return &model.GitusUser{ Name: name, Title: name, Email: email, @@ -758,11 +758,11 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) Website: "", PasswordHash: passwordHash, RegisterTime: t.Unix(), - Status: model.AegisUserStatus(status), + Status: model.GitusUserStatus(status), }, nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateUserInfo(name string, uobj *model.AegisUser) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateUserInfo(name string, uobj *model.GitusUser) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -779,7 +779,7 @@ WHERE user_name = $6 return nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateUserPassword(name string, newPasswordHash string) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateUserPassword(name string, newPasswordHash string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -796,7 +796,7 @@ WHERE user_name = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) HardDeleteUserByName(name string) error { +func (dbif *PostgresGitusDatabaseInterface) HardDeleteUserByName(name string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -811,7 +811,7 @@ DELETE FROM %s_user WHERE user_name = $1 return nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateUserStatus(name string, newStatus model.AegisUserStatus) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateUserStatus(name string, newStatus model.GitusUserStatus) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -828,7 +828,7 @@ WHERE user_name = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) RegisterNamespace(name string, ownerUsername string) (*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) RegisterNamespace(name string, ownerUsername string) (*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -864,7 +864,7 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8) }, nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateNamespaceInfo(name string, nsobj *model.Namespace) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateNamespaceInfo(name string, nsobj *model.Namespace) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -881,7 +881,7 @@ WHERE ns_name = $6 return nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateNamespaceOwner(name string, newOwner string) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateNamespaceOwner(name string, newOwner string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -898,7 +898,7 @@ WHERE ns_name = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateNamespaceStatus(name string, newStatus model.AegisNamespaceStatus) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateNamespaceStatus(name string, newStatus model.GitusNamespaceStatus) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -915,7 +915,7 @@ WHERE ns_name = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) HardDeleteNamespaceByName(name string) error { +func (dbif *PostgresGitusDatabaseInterface) HardDeleteNamespaceByName(name string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -930,7 +930,7 @@ DELETE FROM %s_namespace WHERE ns_name = $1 return nil } -func (dbif *PostgresAegisDatabaseInterface) CreateRepository(ns string, name string, repoType uint8, owner string) (*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) CreateRepository(ns string, name string, repoType uint8, owner string) (*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -961,7 +961,7 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) return r, nil } -func (dbif *PostgresAegisDatabaseInterface) SetUpCloneRepository(originNs string, originName string, targetNs string, targetName string, owner string) (*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) SetUpCloneRepository(originNs string, originName string, targetNs string, targetName string, owner string) (*model.Repository, error) { // TODO: fix this for multi vcs support pfx := dbif.config.Database.TablePrefix ctx := context.Background() @@ -995,7 +995,7 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) return r, nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateRepositoryInfo(ns string, name string, robj *model.Repository) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateRepositoryInfo(ns string, name string, robj *model.Repository) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -1011,7 +1011,7 @@ WHERE repo_namespace = $4 AND repo_name = $5 return nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateRepositoryStatus(ns string, name string, status model.AegisRepositoryStatus) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateRepositoryStatus(ns string, name string, status model.GitusRepositoryStatus) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -1027,7 +1027,7 @@ WHERE repo_namespace = $2 AND repo_name = $3 return nil } -func (dbif *PostgresAegisDatabaseInterface) HardDeleteRepository(ns string, name string) error { +func (dbif *PostgresGitusDatabaseInterface) HardDeleteRepository(ns string, name string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -1042,7 +1042,7 @@ WHERE repo_namespace = $1 AND repo_name = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllUsers(pageNum int64, pageSize int64) ([]*model.AegisUser, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllUsers(pageNum int64, pageSize int64) ([]*model.GitusUser, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -1052,14 +1052,14 @@ ORDER BY user_id ASC LIMIT $1 OFFSET $2 `, pfx), pageSize, pageNum*pageSize) if err != nil { return nil, err } defer stmt.Close() - res := make([]*model.AegisUser, 0) + res := make([]*model.GitusUser, 0) var name, title, email, bio, website, hash string var rt time.Time var status int for stmt.Next() { err := stmt.Scan(&name, &title, &email, &bio, &website, &rt, &hash, &status) if err != nil { return nil, err } - res = append(res, &model.AegisUser{ + res = append(res, &model.GitusUser{ Name: name, Title: title, Email: email, @@ -1067,13 +1067,13 @@ ORDER BY user_id ASC LIMIT $1 OFFSET $2 Website: website, PasswordHash: hash, RegisterTime: rt.Unix(), - Status: model.AegisUserStatus(status), + Status: model.GitusUserStatus(status), }) } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllNamespaces(pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllNamespaces(pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -1100,7 +1100,7 @@ ORDER BY ns_absid ASC LIMIT $1 OFFSET $2 Email: email, Owner: owner, RegisterTime: rt.Unix(), - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), ACL: a, RepositoryList: nil, LocalPath: p, @@ -1109,7 +1109,7 @@ ORDER BY ns_absid ASC LIMIT $1 OFFSET $2 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllRepositories(pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllRepositories(pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -1146,7 +1146,7 @@ ORDER BY repo_absid ASC LIMIT $1 OFFSET $2 Owner: owner, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(rStatus), + Status: model.GitusRepositoryStatus(rStatus), Repository: lr, ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -1157,7 +1157,7 @@ ORDER BY repo_absid ASC LIMIT $1 OFFSET $2 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllUser() (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllUser() (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -1169,7 +1169,7 @@ SELECT COUNT(*) FROM %s_user return r, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllNamespace() (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllNamespace() (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -1181,7 +1181,7 @@ SELECT COUNT(*) FROM %s_namespace return r, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllRepositories() (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllRepositories() (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -1193,7 +1193,7 @@ SELECT COUNT(*) FROM %s_repository return r, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllRepositoriesSearchResult(q string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllRepositoriesSearchResult(q string) (int64, error) { if len(q) <= 0 { return dbif.CountAllRepositories() } pfx := dbif.config.Database.TablePrefix ctx := context.Background() @@ -1206,7 +1206,7 @@ SELECT COUNT(*) FROM %s_repository WHERE repo_ns LIKE $1 ESCAPE $2 OR repo_name return r, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllVisibleNamespace(username string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllVisibleNamespace(username string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Row @@ -1225,7 +1225,7 @@ SELECT COUNT(*) FROM %s_namespace WHERE ns_status = 1 return r, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllVisibleRepositories(username string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllVisibleRepositories(username string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Row @@ -1250,7 +1250,7 @@ WHERE repo_status = 1 or repo_status = 4 return r, nil } -func (dbif *PostgresAegisDatabaseInterface) SearchForUser(k string, pageNum int64, pageSize int64) ([]*model.AegisUser, error) { +func (dbif *PostgresGitusDatabaseInterface) SearchForUser(k string, pageNum int64, pageSize int64) ([]*model.GitusUser, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() pattern := db.ToSqlSearchPattern(k) @@ -1262,20 +1262,20 @@ ORDER BY user_id ASC LIMIT $3 OFFSET $4 `, pfx), pattern, "%", pageSize, pageNum*pageSize) if err != nil { return nil, err } defer stmt.Close() - res := make([]*model.AegisUser, 0) + res := make([]*model.GitusUser, 0) var name, title, email, bio, website, hash string var dt time.Time var st int for stmt.Next() { err = stmt.Scan(&name, &title, &email, &bio, &website, &dt, &hash, &st) if err != nil { return nil, err } - res = append(res, &model.AegisUser{ + res = append(res, &model.GitusUser{ Name: name, Title: title, Email: email, Bio: bio, Website: website, - Status: model.AegisUserStatus(st), + Status: model.GitusUserStatus(st), PasswordHash: hash, RegisterTime: dt.Unix(), }) @@ -1283,7 +1283,7 @@ ORDER BY user_id ASC LIMIT $3 OFFSET $4 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) SearchForNamespace(k string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) SearchForNamespace(k string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() pattern := db.ToSqlSearchPattern(k) @@ -1312,13 +1312,13 @@ ORDER BY ns_absid ASC LIMIT $3 OFFSET $4 Owner: owner, RegisterTime: regtime.Unix(), ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) SearchForRepository(k string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) SearchForRepository(k string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() pattern := db.ToSqlSearchPattern(k) @@ -1354,7 +1354,7 @@ ORDER BY repo_absid ASC LIMIT $3 OFFSET $4 Description: desc, Owner: owner, AccessControlList: a, - Status: model.AegisRepositoryStatus(rStatus), + Status: model.GitusRepositoryStatus(rStatus), Type: uint8(rType), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -1366,7 +1366,7 @@ ORDER BY repo_absid ASC LIMIT $3 OFFSET $4 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) SetNamespaceACL(nsName string, targetUserName string, acl *model.ACLTuple) error { +func (dbif *PostgresGitusDatabaseInterface) SetNamespaceACL(nsName string, targetUserName string, acl *model.ACLTuple) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -1390,7 +1390,7 @@ UPDATE %s_namespace SET ns_acl = jsonb_set(ns_acl, $1, $2) WHERE ns_name = $3 return nil } -func (dbif *PostgresAegisDatabaseInterface) SetRepositoryACL(nsName string, repoName string, targetUserName string, acl *model.ACLTuple) error { +func (dbif *PostgresGitusDatabaseInterface) SetRepositoryACL(nsName string, repoName string, targetUserName string, acl *model.ACLTuple) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -1413,7 +1413,7 @@ UPDATE %s_repository SET repo_acl = jsonb_set(repo_acl, $1, $2) WHERE repo_names return nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllComprisingNamespace(username string) (map[string]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllComprisingNamespace(username string) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -1440,13 +1440,13 @@ WHERE ns_owner = $1 OR ns_acl->'acl' ? $1 Owner: owner, RegisterTime: datetime.Unix(), ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllVisibleNamespaceSearchResult(username string, pattern string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllVisibleNamespaceSearchResult(username string, pattern string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var err error @@ -1484,7 +1484,7 @@ WHERE ns_status = 1 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllVisibleRepositoriesSearchResult(username string, pattern string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllVisibleRepositoriesSearchResult(username string, pattern string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var err error @@ -1543,7 +1543,7 @@ WHERE (repo_status = 1 OR repo_status = 4) return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllRepositoryIssue(ns string, name string) ([]*model.Issue, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllRepositoryIssue(ns string, name string) ([]*model.Issue, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -1574,7 +1574,7 @@ WHERE repo_namespace = $1 AND repo_name = $2 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetRepositoryIssue(ns string, name string, iid int) (*model.Issue, error) { +func (dbif *PostgresGitusDatabaseInterface) GetRepositoryIssue(ns string, name string, iid int) (*model.Issue, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -1603,7 +1603,7 @@ WHERE repo_namespace = $1 AND repo_name = $2 AND issue_id = $3 }, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllRepositoryIssue(ns string, name string) (int, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllRepositoryIssue(ns string, name string) (int, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -1620,7 +1620,7 @@ WHERE repo_namespace = $1 AND repo_name = $2 // filterType: 0 - all, 1 - open, 2 - closed, 3 - solved, 4 - discarded // when query = "" it looks for all issue. -func (dbif *PostgresAegisDatabaseInterface) CountIssue(query string, namespace string, name string, filterType int) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountIssue(query string, namespace string, name string, filterType int) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() statusClause := "" @@ -1653,7 +1653,7 @@ AND %s return res, nil } -func (dbif *PostgresAegisDatabaseInterface) SearchIssuePaginated(query string, namespace string, name string, filterType int, pageNum int64, pageSize int64) ([]*model.Issue, error) { +func (dbif *PostgresGitusDatabaseInterface) SearchIssuePaginated(query string, namespace string, name string, filterType int, pageNum int64, pageSize int64) ([]*model.Issue, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() statusClause := "" @@ -1708,7 +1708,7 @@ ORDER BY issue_priority DESC, issue_timestamp DESC LIMIT $3 OFFSET $4 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) NewRepositoryIssue(ns string, name string, author string, title string, content string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) NewRepositoryIssue(ns string, name string, author string, title string, content string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt1 := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -1732,7 +1732,7 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) return newid, nil } -func (dbif *PostgresAegisDatabaseInterface) HardDeleteRepositoryIssue(ns string, name string, issueId int) error { +func (dbif *PostgresGitusDatabaseInterface) HardDeleteRepositoryIssue(ns string, name string, issueId int) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -1746,7 +1746,7 @@ DELETE FROM %s_issue WHERE repo_namespace = $1 AND repo_name = $2 AND issue_id = return nil } -func (dbif *PostgresAegisDatabaseInterface) SetIssuePriority(namespace string, name string, id int64, priority int) error { +func (dbif *PostgresGitusDatabaseInterface) SetIssuePriority(namespace string, name string, id int64, priority int) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -1760,7 +1760,7 @@ UPDATE %s_issue SET issue_priority = $1 WHERE issue_id = $2 AND repo_namespace = return nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllIssueEvent(ns string, name string, issueId int) ([]*model.IssueEvent, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllIssueEvent(ns string, name string, issueId int) ([]*model.IssueEvent, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt1 := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -1794,7 +1794,7 @@ FROM %s_issue_event WHERE issue_absid = $1 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) NewRepositoryIssueEvent(ns string, name string, issueId int64, eType int, author string, content string) error { +func (dbif *PostgresGitusDatabaseInterface) NewRepositoryIssueEvent(ns string, name string, issueId int64, eType int, author string, content string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt1 := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -1832,7 +1832,7 @@ UPDATE %s_issue SET issue_status = $1 WHERE issue_absid = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) HardDeleteRepositoryIssueEvent(eventAbsId int64) error { +func (dbif *PostgresGitusDatabaseInterface) HardDeleteRepositoryIssueEvent(eventAbsId int64) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -1847,7 +1847,7 @@ DELETE FROM %s_issue_event WHERE issue_event_absid = $1 return nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllBelongingNamespace(viewingUser string, user string) ([]*model.Namespace, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllBelongingNamespace(viewingUser string, user string) ([]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -1890,13 +1890,13 @@ FROM %s_namespace WHERE (ns_status = 1) AND (ns_owner = $1 OR ns_acl->'acl' ? $1 Owner: owner, RegisterTime: datetime.Unix(), ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), }) } return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllBelongingRepository(viewingUser string, user string, query string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllBelongingRepository(viewingUser string, user string, query string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -1980,7 +1980,7 @@ ORDER BY repo_absid ASC LIMIT $2 OFFSET $3 Description: desc, Owner: owner, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: lr, ForkOriginNamespace: forkOriginNamespace, ForkOriginName: forkOriginName, @@ -1990,7 +1990,7 @@ ORDER BY repo_absid ASC LIMIT $2 OFFSET $3 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllBelongingRepository(viewingUser string, user string, query string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllBelongingRepository(viewingUser string, user string, query string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Row @@ -2043,7 +2043,7 @@ AND (repo_name LIKE $2 ESCAPE $3 OR repo_namespace LIKE $2 ESCAPE $3) return r, nil } -func (dbif *PostgresAegisDatabaseInterface) GetForkRepositoryOfUser(username string, originNamespace string, originName string) ([]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) GetForkRepositoryOfUser(username string, originNamespace string, originName string) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -2077,7 +2077,7 @@ WHERE repo_owner = $1 AND repo_fork_origin_namespace = $2 AND repo_fork_origin_n mr.AbsId = rowid mr.Owner = username mr.Type = repoType - mr.Status = model.AegisRepositoryStatus(status) + mr.Status = model.GitusRepositoryStatus(status) mr.ForkOriginNamespace = originNamespace mr.ForkOriginName = originName mr.RepoLabelList = tags @@ -2089,7 +2089,7 @@ WHERE repo_owner = $1 AND repo_fork_origin_namespace = $2 AND repo_fork_origin_n return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllPullRequestPaginated(namespace string, name string, pageNum int64, pageSize int64) ([]*model.PullRequest, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllPullRequestPaginated(namespace string, name string, pageNum int64, pageSize int64) ([]*model.PullRequest, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -2132,7 +2132,7 @@ ORDER BY pull_request_id ASC LIMIT $3 OFFSET $4 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) NewPullRequest(username string, title string, receiverNamespace string, receiverName string, receiverBranch string, providerNamespace string, providerName string, providerBranch string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) NewPullRequest(username string, title string, receiverNamespace string, receiverName string, receiverBranch string, providerNamespace string, providerName string, providerBranch string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt1 := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2154,7 +2154,7 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) return newId, nil } -func (dbif *PostgresAegisDatabaseInterface) GetPullRequest(namespace string, name string, id int64) (*model.PullRequest, error) { +func (dbif *PostgresGitusDatabaseInterface) GetPullRequest(namespace string, name string, id int64) (*model.PullRequest, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2191,7 +2191,7 @@ WHERE receiver_namespace = $1 AND receiver_name = $2 AND pull_request_id = $3 }, nil } -func (dbif *PostgresAegisDatabaseInterface) GetPullRequestByAbsId(absId int64) (*model.PullRequest, error) { +func (dbif *PostgresGitusDatabaseInterface) GetPullRequestByAbsId(absId int64) (*model.PullRequest, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2228,7 +2228,7 @@ WHERE receiver_namespace = $1 AND receiver_name = $2 AND pull_request_id = $3 }, nil } -func (dbif *PostgresAegisDatabaseInterface) CheckPullRequestMergeConflict(absId int64) (*gitlib.MergeCheckResult, error) { +func (dbif *PostgresGitusDatabaseInterface) CheckPullRequestMergeConflict(absId int64) (*gitlib.MergeCheckResult, error) { // WARNING: currently only works when when the source & // the target is git repo. currently (2025.8.27) this check // is performed at the controller side, i.e. users cannot @@ -2268,7 +2268,7 @@ WHERE pull_request_absid = $1 return mr, nil } -func (dbif *PostgresAegisDatabaseInterface) DeletePullRequest(absId int64) error { +func (dbif *PostgresGitusDatabaseInterface) DeletePullRequest(absId int64) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2283,7 +2283,7 @@ DELETE FROM %s_pull_request WHERE pull_request_absid = $1 return nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllPullRequestEventPaginated(absId int64, pageNum int64, pageSize int64) ([]*model.PullRequestEvent, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllPullRequestEventPaginated(absId int64, pageNum int64, pageSize int64) ([]*model.PullRequestEvent, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -2312,7 +2312,7 @@ ORDER BY event_timestamp ASC LIMIT $2 OFFSET $3 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) CheckAndMergePullRequest(absId int64, username string) error { +func (dbif *PostgresGitusDatabaseInterface) CheckAndMergePullRequest(absId int64, username string) error { // WARNING: currently only works when when the source & // the target is git repo. currently (2025.8.27) this check // is performed at the controller side, i.e. users cannot @@ -2386,7 +2386,7 @@ VALUES ($1,$2,$3,$4,$5) return nil } -func (dbif *PostgresAegisDatabaseInterface) CommentOnPullRequest(absId int64, author string, content string) (*model.PullRequestEvent, error) { +func (dbif *PostgresGitusDatabaseInterface) CommentOnPullRequest(absId int64, author string, content string) (*model.PullRequestEvent, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2408,7 +2408,7 @@ INSERT INTO %s_pull_request_event(pull_request_absid, event_type, event_timestam }, nil } -func (dbif *PostgresAegisDatabaseInterface) CommentOnPullRequestCode(absId int64, comment *model.PullRequestCommentOnCode) (*model.PullRequestEvent, error) { +func (dbif *PostgresGitusDatabaseInterface) CommentOnPullRequestCode(absId int64, comment *model.PullRequestCommentOnCode) (*model.PullRequestEvent, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2433,7 +2433,7 @@ VALUES ($1,$2,$3,$4,$5) }, nil } -func (dbif *PostgresAegisDatabaseInterface) ClosePullRequestAsNotMerged(absid int64, author string) error { +func (dbif *PostgresGitusDatabaseInterface) ClosePullRequestAsNotMerged(absid int64, author string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2456,7 +2456,7 @@ WHERE pull_request_absid = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) ReopenPullRequest(absid int64, author string) error { +func (dbif *PostgresGitusDatabaseInterface) ReopenPullRequest(absid int64, author string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2479,7 +2479,7 @@ WHERE pull_request_absid = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) CountPullRequest(query string, namespace string, name string, filterType int) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountPullRequest(query string, namespace string, name string, filterType int) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() statusClause := "" @@ -2507,7 +2507,7 @@ WHERE receiver_namespace = $1 AND receiver_name = $2 %s return res, nil } -func (dbif *PostgresAegisDatabaseInterface) SearchPullRequestPaginated(query string, namespace string, name string, filterType int, pageNum int64, pageSize int64) ([]*model.PullRequest, error) { +func (dbif *PostgresGitusDatabaseInterface) SearchPullRequestPaginated(query string, namespace string, name string, filterType int, pageNum int64, pageSize int64) ([]*model.PullRequest, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() statusClause := "" @@ -2573,7 +2573,7 @@ ORDER BY pull_request_timestamp DESC LIMIT $3 OFFSET $4 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllRegisteredEmailOfUser(username string) ([]struct{Email string;Verified bool}, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllRegisteredEmailOfUser(username string) ([]struct{Email string;Verified bool}, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -2595,7 +2595,7 @@ SELECT email, email_verified FROM %s_user_email WHERE username = $1 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) AddEmail(username string, email string) error { +func (dbif *PostgresGitusDatabaseInterface) AddEmail(username string, email string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2610,7 +2610,7 @@ INSERT INTO %s_user_email(username, email, email_verified) VALUES ($1, $2, 0) return nil } -func (dbif *PostgresAegisDatabaseInterface) VerifyRegisteredEmail(username string, email string) error { +func (dbif *PostgresGitusDatabaseInterface) VerifyRegisteredEmail(username string, email string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2625,7 +2625,7 @@ UPDATE %s_user_email SET email_verified = 1 WHERE username = $1 AND email = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) DeleteRegisteredEmail(username string, email string) error { +func (dbif *PostgresGitusDatabaseInterface) DeleteRegisteredEmail(username string, email string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2640,7 +2640,7 @@ DELETE FROM %s_user_email WHERE username = $1 AND email = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) CheckIfEmailVerified(username string, email string) (bool, error) { +func (dbif *PostgresGitusDatabaseInterface) CheckIfEmailVerified(username string, email string) (bool, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2652,7 +2652,7 @@ SELECT email_verified FROM %s_user_email WHERE username = $1 AND email = $2 return r == 1, nil } -func (dbif *PostgresAegisDatabaseInterface) ResolveEmailToUsername(email string) (string, error) { +func (dbif *PostgresGitusDatabaseInterface) ResolveEmailToUsername(email string) (string, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2664,7 +2664,7 @@ SELECT username FROM %s_user_email WHERE email = $1 AND email_verified = 1 return r, nil } -func (dbif *PostgresAegisDatabaseInterface) ResolveMultipleEmailToUsername(emailList map[string]string) (map[string]string, error) { +func (dbif *PostgresGitusDatabaseInterface) ResolveMultipleEmailToUsername(emailList map[string]string) (map[string]string, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() l := make([]any, 0) @@ -2689,7 +2689,7 @@ SELECT email, username FROM %s_user_email WHERE email_verified = 1 AND email IN return emailList, nil } -func (dbif *PostgresAegisDatabaseInterface) InsertRegistrationRequest(username string, email string, passwordHash string, reason string) error { +func (dbif *PostgresGitusDatabaseInterface) InsertRegistrationRequest(username string, email string, passwordHash string, reason string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -2704,7 +2704,7 @@ INSERT INTO %s_user_reg_request(username, email, password_hash, reason, timestam return nil } -func (dbif *PostgresAegisDatabaseInterface) ApproveRegistrationRequest(absid int64) error { +func (dbif *PostgresGitusDatabaseInterface) ApproveRegistrationRequest(absid int64) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt1 := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2733,7 +2733,7 @@ DELETE FROM %s_user_reg_request WHERE username = $1 return nil } -func (dbif *PostgresAegisDatabaseInterface) DisapproveRegistrationRequest(absid int64) error { +func (dbif *PostgresGitusDatabaseInterface) DisapproveRegistrationRequest(absid int64) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2755,7 +2755,7 @@ DELETE FROM %s_user_reg_request WHERE username = $1 return nil } -func (dbif *PostgresAegisDatabaseInterface) GetRegistrationRequestPaginated(pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { +func (dbif *PostgresGitusDatabaseInterface) GetRegistrationRequestPaginated(pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -2784,7 +2784,7 @@ ORDER BY timestamp DESC LIMIT $1 OFFSET $2 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetRequestOfUsernamePaginated(username string, pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { +func (dbif *PostgresGitusDatabaseInterface) GetRequestOfUsernamePaginated(username string, pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -2814,7 +2814,7 @@ ORDER BY timestamp DESC LIMIT $2 OFFSET $3 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) CountRegistrationRequest(query string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountRegistrationRequest(query string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var r pgx.Row @@ -2835,7 +2835,7 @@ SELECT COUNT(*) FROM %s_user_reg_request WHERE username LIKE $1 ESCAPE $2 return cnt, nil } -func (dbif *PostgresAegisDatabaseInterface) SearchRegistrationRequestPaginated(query string, pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { +func (dbif *PostgresGitusDatabaseInterface) SearchRegistrationRequestPaginated(query string, pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -2870,7 +2870,7 @@ SELECT request_absid, username, email, password_hash, timestamp FROM %s_user_reg return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetRegistrationRequestByAbsId(absid int64) (*model.RegistrationRequest, error) { +func (dbif *PostgresGitusDatabaseInterface) GetRegistrationRequestByAbsId(absid int64) (*model.RegistrationRequest, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2890,7 +2890,7 @@ SELECT request_absid, username, email, password_hash, timestamp FROM %s_user_reg }, nil } -func (dbif *PostgresAegisDatabaseInterface) AddRepositoryLabel(ns string, name string, lbl string) error { +func (dbif *PostgresGitusDatabaseInterface) AddRepositoryLabel(ns string, name string, lbl string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2919,7 +2919,7 @@ UPDATE %s_repository SET repo_label_list = $1 WHERE repo_namespace = $2 AND repo return nil } -func (dbif *PostgresAegisDatabaseInterface) RemoveRepositoryLabel(ns string, name string, lbl string) error { +func (dbif *PostgresGitusDatabaseInterface) RemoveRepositoryLabel(ns string, name string, lbl string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2944,7 +2944,7 @@ UPDATE %s_repository SET repo_label_list = $1 WHERE repo_namespace = $2 AND repo return nil } -func (dbif *PostgresAegisDatabaseInterface) GetRepositoryLabel(ns string, name string) ([]string, error) { +func (dbif *PostgresGitusDatabaseInterface) GetRepositoryLabel(ns string, name string) ([]string, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -2957,7 +2957,7 @@ SELECT repo_label_list FROM %s_repository WHERE repo_namespace = $1 and repo_nam return tags, nil } -func (dbif *PostgresAegisDatabaseInterface) CountRepositoryWithLabel(username string, label string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountRepositoryWithLabel(username string, label string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var r pgx.Row @@ -2983,7 +2983,7 @@ AND ( return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetRepositoryWithLabelPaginated(username string, label string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *PostgresGitusDatabaseInterface) GetRepositoryWithLabelPaginated(username string, label string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var r pgx.Rows @@ -3034,7 +3034,7 @@ ORDER BY repo_name ASC, repo_namespace ASC LIMIT $5 OFFSET $6 Owner: owner, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: gitlib.NewLocalGitRepository(p), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -3045,7 +3045,7 @@ ORDER BY repo_name ASC, repo_namespace ASC LIMIT $5 OFFSET $6 } -func (dbif *PostgresAegisDatabaseInterface) NewSnippet(username string, name string, status uint8) (*model.Snippet, error) { +func (dbif *PostgresGitusDatabaseInterface) NewSnippet(username string, name string, status uint8) (*model.Snippet, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -3076,7 +3076,7 @@ VALUES ($1, $2, $3, $4, $5, $6) }, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllSnippet(username string) ([]*model.Snippet, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllSnippet(username string) ([]*model.Snippet, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt, err := dbif.pool.Query(ctx, fmt.Sprintf(` @@ -3105,7 +3105,7 @@ WHERE username = $1 return res, nil } -func (dbif *PostgresAegisDatabaseInterface) CountAllVisibleSnippet(username string, viewingUser string, query string) (int64, error) { +func (dbif *PostgresGitusDatabaseInterface) CountAllVisibleSnippet(username string, viewingUser string, query string) (int64, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Row @@ -3152,7 +3152,7 @@ WHERE username = $1 AND (status = 1 OR status = 2 OR (status = 4 AND shared_user return res, nil } -func (dbif *PostgresAegisDatabaseInterface) GetAllVisibleSnippetPaginated(username string, viewingUser string, query string, pageNum int64, pageSize int64) ([]*model.Snippet, error) { +func (dbif *PostgresGitusDatabaseInterface) GetAllVisibleSnippetPaginated(username string, viewingUser string, query string, pageNum int64, pageSize int64) ([]*model.Snippet, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() var stmt pgx.Rows @@ -3215,7 +3215,7 @@ WHERE username = $1 AND (status = 1 OR status = 2 OR (status = 4 AND shared_user return res, nil } -func (dbif *PostgresAegisDatabaseInterface) DeleteSnippet(username string, name string) error { +func (dbif *PostgresGitusDatabaseInterface) DeleteSnippet(username string, name string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -3233,7 +3233,7 @@ DELETE FROM %s_snippet WHERE username = $1 AND name = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) SaveSnippetInfo(m *model.Snippet) error { +func (dbif *PostgresGitusDatabaseInterface) SaveSnippetInfo(m *model.Snippet) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -3250,7 +3250,7 @@ WHERE username = $4 AND name = $5 return nil } -func (dbif *PostgresAegisDatabaseInterface) GetSnippet(username string, name string) (*model.Snippet, error) { +func (dbif *PostgresGitusDatabaseInterface) GetSnippet(username string, name string) (*model.Snippet, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -3277,7 +3277,7 @@ WHERE username = $1 AND name = $2 } -func (dbif *PostgresAegisDatabaseInterface) RegisterWebhookRequest(uuid string, reportUuid string, repoNs string, repoName string, commitId string) error { +func (dbif *PostgresGitusDatabaseInterface) RegisterWebhookRequest(uuid string, reportUuid string, repoNs string, repoName string, commitId string) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -3299,7 +3299,7 @@ VALUES ($1,$2,$3,$4,$5) return nil } -func (dbif *PostgresAegisDatabaseInterface) UpdateWebhookResult(uuid string, result *model.WebhookResult) error { +func (dbif *PostgresGitusDatabaseInterface) UpdateWebhookResult(uuid string, result *model.WebhookResult) error { pfx := dbif.config.Database.TablePrefix ctx := context.Background() tx, err := dbif.pool.Begin(ctx) @@ -3315,7 +3315,7 @@ UPDATE %s_webhook_log SET webhook_result = $1 WHERE uuid = $2 return nil } -func (dbif *PostgresAegisDatabaseInterface) GetWebhookResultByUUID(uuid string) (*model.WebhookResult, error) { +func (dbif *PostgresGitusDatabaseInterface) GetWebhookResultByUUID(uuid string) (*model.WebhookResult, error) { pfx := dbif.config.Database.TablePrefix ctx := context.Background() stmt := dbif.pool.QueryRow(ctx, fmt.Sprintf(` diff --git a/pkg/aegis/db/sqlite/defs.go b/pkg/gitus/db/sqlite/defs.go similarity index 78% rename from pkg/aegis/db/sqlite/defs.go rename to pkg/gitus/db/sqlite/defs.go index 5fb448e..ef469af 100644 --- a/pkg/aegis/db/sqlite/defs.go +++ b/pkg/gitus/db/sqlite/defs.go @@ -4,12 +4,12 @@ import ( "database/sql" "net/url" - "github.com/bctnry/aegis/pkg/aegis" + "github.com/GitusCodeForge/Gitus/pkg/gitus" _ "github.com/mattn/go-sqlite3" ) -type SqliteAegisDatabaseInterface struct { - config *aegis.AegisConfig +type SqliteGitusDatabaseInterface struct { + config *gitus.GitusConfig connection *sql.DB } @@ -29,7 +29,7 @@ var requiredTableList = []string{ "webhook_log", } -func (dbif *SqliteAegisDatabaseInterface) IsDatabaseUsable() (bool, error) { +func (dbif *SqliteGitusDatabaseInterface) IsDatabaseUsable() (bool, error) { stmt, err := dbif.connection.Prepare("SELECT 1 FROM sqlite_schema WHERE type = 'table' AND name = ?") if err != nil { return false, err } for _, item := range requiredTableList { @@ -45,7 +45,7 @@ func (dbif *SqliteAegisDatabaseInterface) IsDatabaseUsable() (bool, error) { return true, nil } -func NewSqliteAegisDatabaseInterface(cfg *aegis.AegisConfig) (*SqliteAegisDatabaseInterface, error) { +func NewSqliteGitusDatabaseInterface(cfg *gitus.GitusConfig) (*SqliteGitusDatabaseInterface, error) { p := cfg.ProperDatabasePath() r, _ := url.Parse(p) q := r.Query() @@ -55,7 +55,7 @@ func NewSqliteAegisDatabaseInterface(cfg *aegis.AegisConfig) (*SqliteAegisDataba r.RawQuery = q.Encode() db, err := sql.Open("sqlite3", r.String()) if err != nil { return nil, err } - return &SqliteAegisDatabaseInterface{ + return &SqliteGitusDatabaseInterface{ config: cfg, connection: db, }, nil diff --git a/pkg/aegis/db/sqlite/install.go b/pkg/gitus/db/sqlite/install.go similarity index 98% rename from pkg/aegis/db/sqlite/install.go rename to pkg/gitus/db/sqlite/install.go index 635572e..6debbc7 100644 --- a/pkg/aegis/db/sqlite/install.go +++ b/pkg/gitus/db/sqlite/install.go @@ -3,7 +3,7 @@ package sqlite import "fmt" -func (dbif *SqliteAegisDatabaseInterface) InstallTables() error { +func (dbif *SqliteGitusDatabaseInterface) InstallTables() error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } diff --git a/pkg/aegis/db/sqlite/query.go b/pkg/gitus/db/sqlite/query.go similarity index 92% rename from pkg/aegis/db/sqlite/query.go rename to pkg/gitus/db/sqlite/query.go index 0251da0..2401544 100644 --- a/pkg/aegis/db/sqlite/query.go +++ b/pkg/gitus/db/sqlite/query.go @@ -14,17 +14,17 @@ import ( "strings" "time" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" _ "github.com/mattn/go-sqlite3" ) -func (dbif *SqliteAegisDatabaseInterface) Dispose() error { +func (dbif *SqliteGitusDatabaseInterface) Dispose() error { return dbif.connection.Close() } -func (dbif *SqliteAegisDatabaseInterface) GetUserByName(name string) (*model.AegisUser, error) { +func (dbif *SqliteGitusDatabaseInterface) GetUserByName(name string) (*model.GitusUser, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT user_name, user_title, user_email, user_bio, user_website, user_status, user_password_hash, user_2fa_config, user_website_preference @@ -37,26 +37,26 @@ WHERE user_name = ? err = stmt.QueryRow(name).Scan(&username, &title, &email, &bio, &website, &status, &ph, &tfaConfig, &websitePreference) if err == sql.ErrNoRows { return nil, db.ErrEntityNotFound } if err != nil { return nil, err } - var tfa model.AegisUser2FAConfig + var tfa model.GitusUser2FAConfig err = json.Unmarshal([]byte(tfaConfig), &tfa) if err != nil { return nil, err } - var wPref model.AegisUserWebsitePreference + var wPref model.GitusUserWebsitePreference err = json.Unmarshal([]byte(websitePreference), &wPref) if err != nil { return nil, err } - return &model.AegisUser{ + return &model.GitusUser{ Name: username, Title: title, Email: email, Bio: bio, Website: website, - Status: model.AegisUserStatus(status), + Status: model.GitusUserStatus(status), PasswordHash: ph, TFAConfig: tfa, WebsitePreference: wPref, }, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAuthKeyByName(userName string, keyName string) (*model.AegisAuthKey, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAuthKeyByName(userName string, keyName string) (*model.GitusAuthKey, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT key_text @@ -75,14 +75,14 @@ WHERE user_name = ? AND key_name = ? kt := "" err = r.Scan(&kt) if err != nil { return nil, err } - return &model.AegisAuthKey{ + return &model.GitusAuthKey{ UserName: userName, KeyName: keyName, KeyText: kt, }, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllAuthKeyByUsername(name string) ([]model.AegisAuthKey, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllAuthKeyByUsername(name string) ([]model.GitusAuthKey, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT key_name, key_text @@ -93,12 +93,12 @@ WHERE user_name = ? r, err := stmt.Query(name) if err != nil { return nil, err } defer r.Close() - res := make([]model.AegisAuthKey, 0) + res := make([]model.GitusAuthKey, 0) for r.Next() { var keyName, keyText string err = r.Scan(&keyName, &keyText) if err != nil { return nil, err } - res = append(res, model.AegisAuthKey{ + res = append(res, model.GitusAuthKey{ UserName: name, KeyText: keyText, KeyName: keyName, @@ -107,7 +107,7 @@ WHERE user_name = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) RegisterAuthKey(username string, keyname string, keytext string) error { +func (dbif *SqliteGitusDatabaseInterface) RegisterAuthKey(username string, keyname string, keytext string) error { pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT 1 FROM %s_user_authkey WHERE user_name = ? AND key_name = ? @@ -135,7 +135,7 @@ VALUES (?,?,?) return nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateAuthKey(username string, keyname string, keytext string) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateAuthKey(username string, keyname string, keytext string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -152,7 +152,7 @@ UPDATE %s_user_authkey SET key_text = ? WHERE user_name = ? AND key_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) RemoveAuthKey(username string, keyname string) error { +func (dbif *SqliteGitusDatabaseInterface) RemoveAuthKey(username string, keyname string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -168,7 +168,7 @@ WHERE user_name = ? AND key_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllSignKeyByUsername(name string) ([]model.AegisSigningKey, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllSignKeyByUsername(name string) ([]model.GitusSigningKey, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT key_name, key_text @@ -179,12 +179,12 @@ WHERE user_name = ? r, err := stmt.Query(name) if err != nil { return nil, err } defer r.Close() - res := make([]model.AegisSigningKey, 0) + res := make([]model.GitusSigningKey, 0) for r.Next() { var keyName, keyText string err = r.Scan(&keyName, &keyText) if err != nil { return nil, err } - res = append(res, model.AegisSigningKey{ + res = append(res, model.GitusSigningKey{ UserName: name, KeyText: keyText, KeyName: keyName, @@ -193,7 +193,7 @@ WHERE user_name = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetSignKeyByName(userName string, keyName string) (*model.AegisSigningKey, error) { +func (dbif *SqliteGitusDatabaseInterface) GetSignKeyByName(userName string, keyName string) (*model.GitusSigningKey, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT key_text FROM %s_user_signkey @@ -206,14 +206,14 @@ WHERE user_name = ? AND key_name = ? var text string err = r.Scan(&text) if err != nil { return nil, err } - return &model.AegisSigningKey{ + return &model.GitusSigningKey{ UserName: userName, KeyName: keyName, KeyText: text, }, nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateSignKey(username string, keyname string, keytext string) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateSignKey(username string, keyname string, keytext string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -230,7 +230,7 @@ UPDATE %s_user_signkey SET key_text = ? WHERE user_name = ? AND key_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) RegisterSignKey(username string, keyname string, keytext string) error { +func (dbif *SqliteGitusDatabaseInterface) RegisterSignKey(username string, keyname string, keytext string) error { pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT 1 FROM %s_user_signkey WHERE user_name = ? AND key_name = ? @@ -258,7 +258,7 @@ VALUES (?,?,?) return nil } -func (dbif *SqliteAegisDatabaseInterface) RemoveSignKey(username string, keyname string) error { +func (dbif *SqliteGitusDatabaseInterface) RemoveSignKey(username string, keyname string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -274,7 +274,7 @@ WHERE user_name = ? AND key_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) RegisterUser(name string, email string, passwordHash string, status model.AegisUserStatus) (*model.AegisUser, error) { +func (dbif *SqliteGitusDatabaseInterface) RegisterUser(name string, email string, passwordHash string, status model.GitusUserStatus) (*model.GitusUser, error) { pfx := dbif.config.Database.TablePrefix t := time.Now().Unix() tx, err := dbif.connection.Begin() @@ -302,7 +302,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) err = os.MkdirAll(userNsPath, os.ModeDir|0755) // TODO: chown. if err != nil { tx.Rollback(); return nil, err } - return &model.AegisUser{ + return &model.GitusUser{ Name: name, Title: name, Email: email, @@ -313,7 +313,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }, nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateUserInfo(name string, uobj *model.AegisUser) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateUserInfo(name string, uobj *model.GitusUser) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -337,7 +337,7 @@ WHERE return nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateUserPassword(name string, newPasswordHash string) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateUserPassword(name string, newPasswordHash string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -355,7 +355,7 @@ WHERE user_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateUserStatus(name string, newStatus model.AegisUserStatus) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateUserStatus(name string, newStatus model.GitusUserStatus) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -373,7 +373,7 @@ WHERE user_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) HardDeleteUserByName(name string) error { +func (dbif *SqliteGitusDatabaseInterface) HardDeleteUserByName(name string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -392,7 +392,7 @@ DELETE FROM %s_user WHERE user_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) GetNamespaceByName(name string) (*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) GetNamespaceByName(name string) (*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT ns_title, ns_description, ns_email, ns_owner, ns_reg_datetime, ns_status, ns_acl @@ -420,11 +420,11 @@ WHERE ns_name = ? Owner: owner, RegisterTime: reg_date, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), }, nil } -func (dbif *SqliteAegisDatabaseInterface) GetRepositoryByName(nsName string, repoName string) (*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) GetRepositoryByName(nsName string, repoName string) (*model.Repository, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT repo_type, repo_description, repo_owner, repo_acl, repo_status, repo_fork_origin_namespace, repo_fork_origin_name, repo_label_list, repo_webhook, rowid @@ -454,7 +454,7 @@ WHERE repo_namespace = ? AND repo_name = ? res.AbsId = rowid res.Type = repoType res.Owner = owner - res.Status = model.AegisRepositoryStatus(status) + res.Status = model.GitusRepositoryStatus(status) res.ForkOriginNamespace = forkOriginNs res.ForkOriginName = forkOriginName res.RepoLabelList = tags @@ -466,7 +466,7 @@ WHERE repo_namespace = ? AND repo_name = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) RegisterNamespace(name string, ownerUsername string) (*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) RegisterNamespace(name string, ownerUsername string) (*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return nil, err } @@ -513,7 +513,7 @@ VALUES (?,?,?,?,?,?,?,?) }, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllVisibleNamespace(username string) (map[string]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllVisibleNamespace(username string) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix var rs *sql.Rows var err error @@ -554,13 +554,13 @@ WHERE ns_status = 1 Owner: owner, RegisterTime: regtime, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllNamespace() (map[string]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllNamespace() (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT ns_name, ns_title, ns_description, ns_email, ns_owner, ns_reg_datetime, ns_status, ns_acl @@ -587,13 +587,13 @@ FROM %s_namespace Owner: owner, RegisterTime: regtime, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllNamespaceByOwner(name string) (map[string]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllNamespaceByOwner(name string) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT ns_name, ns_title, ns_description, ns_email, ns_owner, ns_reg_datetime, ns_status, ns_acl @@ -621,13 +621,13 @@ WHERE ns_status != 3 AND ns_status != 4 AND ns_owner = ? Owner: owner, RegisterTime: regtime, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllVisibleRepositoryFromNamespace(username string, ns string) ([]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllVisibleRepositoryFromNamespace(username string, ns string) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix var rs *sql.Rows var err error @@ -675,7 +675,7 @@ AND (repo_status = 1 OR repo_status = 4) Owner: owner, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: gitlib.NewLocalGitRepository(p), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -686,7 +686,7 @@ AND (repo_status = 1 OR repo_status = 4) return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllRepositoryFromNamespace(ns string) (map[string]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllRepositoryFromNamespace(ns string) (map[string]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT repo_type, repo_name, repo_description, repo_owner, repo_acl, repo_status, repo_fork_origin_namespace, repo_fork_origin_name, repo_label_list, repo_webhook, rowid @@ -721,7 +721,7 @@ WHERE repo_namespace = ? Owner: owner, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: gitlib.NewLocalGitRepository(p), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -732,7 +732,7 @@ WHERE repo_namespace = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateNamespaceInfo(name string, nsobj *model.Namespace) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateNamespaceInfo(name string, nsobj *model.Namespace) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -749,7 +749,7 @@ WHERE ns_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateNamespaceOwner(name string, newOwner string) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateNamespaceOwner(name string, newOwner string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -766,7 +766,7 @@ WHERE ns_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateNamespaceStatus(name string, newStatus model.AegisNamespaceStatus) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateNamespaceStatus(name string, newStatus model.GitusNamespaceStatus) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -783,7 +783,7 @@ WHERE ns_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) HardDeleteNamespaceByName(name string) error { +func (dbif *SqliteGitusDatabaseInterface) HardDeleteNamespaceByName(name string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -801,7 +801,7 @@ DELETE FROM %s_namespace WHERE ns_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) CreateRepository(ns string, name string, repoType uint8, owner string) (*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) CreateRepository(ns string, name string, repoType uint8, owner string) (*model.Repository, error) { pfx := dbif.config.Database.TablePrefix if !model.ValidNamespaceName(ns) || !model.ValidRepositoryName(name) { return nil, db.ErrInvalidLocation @@ -841,7 +841,7 @@ VALUES (?,?,?,?,?,?,?,?,?,?,?,?) return r, nil } -func (dbif *SqliteAegisDatabaseInterface) SetUpCloneRepository(originNs string, originName string, targetNs string, targetName string, owner string) (*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) SetUpCloneRepository(originNs string, originName string, targetNs string, targetName string, owner string) (*model.Repository, error) { // TODO: fix this for multi vcs support pfx := dbif.config.Database.TablePrefix targetFullName := targetNs + ":" + targetName @@ -876,7 +876,7 @@ VALUES (?,?,?,?,?,?,?,?,?,?,?,?) if err != nil { return nil, err } if err = tx.Commit(); err != nil { return nil, err } r, err := model.NewRepository(targetNs, targetName, targetRepo) - r.Type = model.GetAegisType(targetRepo) + r.Type = model.GetGitusType(targetRepo) r.Owner = owner r.RepoLabelList = nil r.WebHookConfig = webhookobj @@ -884,7 +884,7 @@ VALUES (?,?,?,?,?,?,?,?,?,?,?,?) return r, nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateRepositoryInfo(ns string, name string, robj *model.Repository) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateRepositoryInfo(ns string, name string, robj *model.Repository) error { // TODO: these two queries can probaby be combined into one. fix this later. pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` @@ -921,7 +921,7 @@ WHERE rowid = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateRepositoryStatus(ns string, name string, newStatus model.AegisRepositoryStatus) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateRepositoryStatus(ns string, name string, newStatus model.GitusRepositoryStatus) error { // TODO: these two queries can probaby be combined into one. fix this later. pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` @@ -949,7 +949,7 @@ WHERE rowid = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) HardDeleteRepository(ns string, name string) error { +func (dbif *SqliteGitusDatabaseInterface) HardDeleteRepository(ns string, name string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -968,7 +968,7 @@ WHERE repo_namespace = ? AND repo_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllUsers(pageNum int64, pageSize int64) ([]*model.AegisUser, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllUsers(pageNum int64, pageSize int64) ([]*model.GitusUser, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT user_name, user_title, user_email, user_bio, user_website, user_status, user_password_hash @@ -980,26 +980,26 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? r, err := stmt.Query(pageSize, pageNum * pageSize) if err != nil { return nil, err } defer r.Close() - res := make([]*model.AegisUser, 0) + res := make([]*model.GitusUser, 0) var username, title, email, bio, website, ph string var status int for r.Next() { err = r.Scan(&username, &title, &email, &bio, &website, &status, &ph) if err != nil { return nil, err } - res = append(res, &model.AegisUser{ + res = append(res, &model.GitusUser{ Name: username, Title: title, Email: email, Bio: bio, Website: website, - Status: model.AegisUserStatus(status), + Status: model.GitusUserStatus(status), PasswordHash: ph, }) } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllNamespaces(pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllNamespaces(pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT ns_name, ns_title, ns_description, ns_email, ns_owner, ns_reg_datetime, ns_status, ns_acl @@ -1028,13 +1028,13 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Owner: owner, RegisterTime: reg_date, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllRepositories(pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllRepositories(pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT repo_type, repo_namespace, repo_name, repo_description, repo_acl, repo_owner, repo_status, repo_fork_origin_namespace, repo_fork_origin_name, repo_label_list, repo_webhook @@ -1071,7 +1071,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Owner: owner, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: lr, ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -1082,7 +1082,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllUser() (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllUser() (int64, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare( fmt.Sprintf(`SELECT COUNT(*) FROM %s_user`, pfx), @@ -1097,7 +1097,7 @@ func (dbif *SqliteAegisDatabaseInterface) CountAllUser() (int64, error) { return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllNamespace() (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllNamespace() (int64, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare( fmt.Sprintf(`SELECT COUNT(*) FROM %s_namespace`, pfx), @@ -1112,7 +1112,7 @@ func (dbif *SqliteAegisDatabaseInterface) CountAllNamespace() (int64, error) { return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllRepositoriesSearchResult(q string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllRepositoriesSearchResult(q string) (int64, error) { pfx := dbif.config.Database.TablePrefix searchPattern := strings.ReplaceAll(q, "\\", "\\\\") searchPattern = strings.ReplaceAll(searchPattern, "%", "\\%") @@ -1133,7 +1133,7 @@ WHERE (repo_name LIKE ? ESCAPE ? OR repo_namespace LIKE ? ESCAPE ?)`, pfx), return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllRepositories() (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllRepositories() (int64, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare( fmt.Sprintf(`SELECT COUNT(*) FROM %s_repository`, pfx), @@ -1148,7 +1148,7 @@ func (dbif *SqliteAegisDatabaseInterface) CountAllRepositories() (int64, error) return res, nil } -func (dbif *SqliteAegisDatabaseInterface) SearchForUser(k string, pageNum int64, pageSize int64) ([]*model.AegisUser, error) { +func (dbif *SqliteGitusDatabaseInterface) SearchForUser(k string, pageNum int64, pageSize int64) ([]*model.GitusUser, error) { pfx := dbif.config.Database.TablePrefix pattern := db.ToSqlSearchPattern(k) stmt, err := dbif.connection.Prepare(fmt.Sprintf(` @@ -1162,26 +1162,26 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? r, err := stmt.Query(pattern, "\\", pattern, "\\", pageSize, pageNum * pageSize) if err != nil { return nil, err } defer r.Close() - res := make([]*model.AegisUser, 0) + res := make([]*model.GitusUser, 0) var username, title, email, bio, website, ph string var status int for r.Next() { err = r.Scan(&username, &title, &email, &bio, &website, &status, &ph) if err != nil { return nil, err } - res = append(res, &model.AegisUser{ + res = append(res, &model.GitusUser{ Name: username, Title: title, Email: email, Bio: bio, Website: website, - Status: model.AegisUserStatus(status), + Status: model.GitusUserStatus(status), PasswordHash: ph, }) } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) SearchForNamespace(k string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) SearchForNamespace(k string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix pattern := strings.ReplaceAll(k, "\\", "\\\\") pattern = strings.ReplaceAll(pattern, "%", "\\%") @@ -1215,13 +1215,13 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Owner: owner, RegisterTime: reg_date, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) SearchForRepository(k string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) SearchForRepository(k string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix pattern := strings.ReplaceAll(k, "\\", "\\\\") pattern = strings.ReplaceAll(pattern, "%", "\\%") @@ -1264,7 +1264,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Name: name, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: lr, ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -1275,7 +1275,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) SetNamespaceACL(nsName string, targetUserName string, aclt *model.ACLTuple) error { +func (dbif *SqliteGitusDatabaseInterface) SetNamespaceACL(nsName string, targetUserName string, aclt *model.ACLTuple) error { pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT ns_acl FROM %s_namespace WHERE ns_name = ? @@ -1312,7 +1312,7 @@ UPDATE %s_namespace SET ns_acl = ? WHERE ns_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) SetRepositoryACL(nsName string, repoName string, targetUserName string, aclt *model.ACLTuple) error { +func (dbif *SqliteGitusDatabaseInterface) SetRepositoryACL(nsName string, repoName string, targetUserName string, aclt *model.ACLTuple) error { pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT repo_acl FROM %s_repository WHERE repo_namespace = ? AND repo_name = ? @@ -1349,7 +1349,7 @@ UPDATE %s_repository SET repo_acl = ? WHERE repo_namespace = ? AND repo_name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllComprisingNamespace(username string) (map[string]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllComprisingNamespace(username string) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix pattern := strings.ReplaceAll(username, "\\", "\\\\") pattern = strings.ReplaceAll(pattern, "%", "\\%") @@ -1382,13 +1382,13 @@ WHERE ns_owner = ? OR ns_acl LIKE ? ESCAPE ? Owner: owner, RegisterTime: regtime, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllVisibleNamespacePaginated(username string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllVisibleNamespacePaginated(username string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix privateSelectClause := "" if len(username) > 0 { @@ -1431,13 +1431,13 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Owner: owner, RegisterTime: regtime, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllVisibleRepositoryPaginated(username string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllVisibleRepositoryPaginated(username string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix var rs *sql.Rows var stmt *sql.Stmt @@ -1499,7 +1499,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Owner: owner, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: lr, ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -1510,15 +1510,15 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllVisibleNamespace(username string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllVisibleNamespace(username string) (int64, error) { return dbif.CountAllVisibleNamespaceSearchResult(username, "") } -func (dbif *SqliteAegisDatabaseInterface) CountAllVisibleRepositories(username string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllVisibleRepositories(username string) (int64, error) { return dbif.CountAllVisibleRepositoriesSearchResult(username, "") } -func (dbif *SqliteAegisDatabaseInterface) SearchAllVisibleNamespacePaginated(username string, query string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) SearchAllVisibleNamespacePaginated(username string, query string, pageNum int64, pageSize int64) (map[string]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix var rs *sql.Rows var stmt *sql.Stmt @@ -1590,13 +1590,13 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Owner: owner, RegisterTime: reg_date, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), } } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) SearchAllVisibleRepositoryPaginated(username string, query string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) SearchAllVisibleRepositoryPaginated(username string, query string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Rows var err error @@ -1694,7 +1694,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Name: name, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: lr, ForkOriginNamespace: forkOriginNamespace, ForkOriginName: forkOriginName, @@ -1705,7 +1705,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? } -func (dbif *SqliteAegisDatabaseInterface) CountAllVisibleNamespaceSearchResult(username string, pattern string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllVisibleNamespaceSearchResult(username string, pattern string) (int64, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Row var err error @@ -1752,7 +1752,7 @@ SELECT COUNT(*) FROM %s_namespace WHERE (ns_status = 1 OR ns_status = 3) return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllVisibleRepositoriesSearchResult(username string, pattern string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllVisibleRepositoriesSearchResult(username string, pattern string) (int64, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Row var err error @@ -1824,7 +1824,7 @@ WHERE ( return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllRepositoryIssue(ns string, name string) ([]*model.Issue, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllRepositoryIssue(ns string, name string) ([]*model.Issue, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT rowid, issue_id, issue_author, issue_status, issue_title, issue_content, issue_timestamp @@ -1858,7 +1858,7 @@ WHERE repo_namespace = ? AND repo_name = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetRepositoryIssue(ns string, name string, iid int) (*model.Issue, error) { +func (dbif *SqliteGitusDatabaseInterface) GetRepositoryIssue(ns string, name string, iid int) (*model.Issue, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT rowid, issue_timestamp, issue_author, issue_title, issue_content, issue_status, issue_priority @@ -1888,7 +1888,7 @@ WHERE repo_namespace = ? AND repo_name = ? AND issue_id = ? }, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllRepositoryIssue(ns string, name string) (int, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllRepositoryIssue(ns string, name string) (int, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT COUNT(*) @@ -1905,7 +1905,7 @@ WHERE repo_namespace = ? AND repo_name = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) NewRepositoryIssue(ns string, name string, author string, title string, content string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) NewRepositoryIssue(ns string, name string, author string, title string, content string) (int64, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT COUNT(*) FROM %s_issue WHERE repo_namespace = ? AND repo_name = ? @@ -1933,7 +1933,7 @@ VALUES (?,?,?,?,?,?,?,?,?) return res, nil } -func (dbif *SqliteAegisDatabaseInterface) HardDeleteRepositoryIssue(ns string, name string, issueId int) error { +func (dbif *SqliteGitusDatabaseInterface) HardDeleteRepositoryIssue(ns string, name string, issueId int) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -1950,7 +1950,7 @@ DELETE FROM %s_issue WHERE repo_namespace = ? AND repo_name = ? AND issue_id = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) SetIssuePriority(namespace string, name string, id int64, priority int) error { +func (dbif *SqliteGitusDatabaseInterface) SetIssuePriority(namespace string, name string, id int64, priority int) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -1966,7 +1966,7 @@ UPDATE %s_issue SET issue_priority = ? WHERE repo_namespace = ? AND repo_name = return nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllIssueEvent(ns string, name string, issueId int) ([]*model.IssueEvent, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllIssueEvent(ns string, name string, issueId int) ([]*model.IssueEvent, error) { pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT rowid FROM %s_issue WHERE repo_namespace = ? AND repo_name = ? AND issue_id = ? @@ -2006,7 +2006,7 @@ WHERE issue_abs_id = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) NewRepositoryIssueEvent(ns string, name string, issueId int64, eType int, author string, content string) error { +func (dbif *SqliteGitusDatabaseInterface) NewRepositoryIssueEvent(ns string, name string, issueId int64, eType int, author string, content string) error { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT rowid, issue_status FROM %s_issue WHERE repo_namespace = ? AND repo_name = ? AND issue_id = ? @@ -2052,7 +2052,7 @@ UPDATE %s_issue SET issue_status = ? WHERE rowid = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) HardDeleteRepositoryIssueEvent(eventAbsId int64) error { +func (dbif *SqliteGitusDatabaseInterface) HardDeleteRepositoryIssueEvent(eventAbsId int64) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -2069,7 +2069,7 @@ DELETE FROM %s_issue_event WHERE rowid = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllBelongingNamespace(viewingUser string, userName string) ([]*model.Namespace, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllBelongingNamespace(viewingUser string, userName string) ([]*model.Namespace, error) { pfx := dbif.config.Database.TablePrefix nsStatusClause := "ns_status = 1" if len(viewingUser) > 0 { @@ -2116,13 +2116,13 @@ WHERE (%s) AND (ns_owner = ? OR ns_acl LIKE ? ESCAPE ?) Owner: owner, RegisterTime: regtime, ACL: a, - Status: model.AegisNamespaceStatus(status), + Status: model.GitusNamespaceStatus(status), }) } return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllBelongingRepository(viewingUser string, user string, query string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllBelongingRepository(viewingUser string, user string, query string, pageNum int64, pageSize int64) ([]*model.Repository, error) { // the fact that go does not have if-expr is killing me. // NOTE: // + if viewingUser is empty, it means the viewing user is a guest, @@ -2235,7 +2235,7 @@ ORDER BY repo_name ASC, repo_namespace ASC Description: desc, Owner: owner, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: lr, ForkOriginNamespace: forkOriginNamespace, ForkOriginName: forkOriginName, @@ -2245,7 +2245,7 @@ ORDER BY repo_name ASC, repo_namespace ASC return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllBelongingRepository(viewingUser string, user string, query string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllBelongingRepository(viewingUser string, user string, query string) (int64, error) { pfx := dbif.config.Database.TablePrefix var stmt *sql.Stmt var r *sql.Row @@ -2319,7 +2319,7 @@ AND (repo_name LIKE ? ESCAPE ? OR repo_namespace LIKE ? ESCAPE ?) return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetForkRepositoryOfUser(username string, originNamespace string, originName string) ([]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) GetForkRepositoryOfUser(username string, originNamespace string, originName string) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT repo_type, repo_namespace, repo_name, repo_description, repo_acl, repo_status, repo_label_list, rowid @@ -2354,7 +2354,7 @@ WHERE repo_owner = ? AND repo_fork_origin_namespace = ? AND repo_fork_origin_nam mr.AbsId = rowid mr.Owner = username mr.Type = repoType - mr.Status = model.AegisRepositoryStatus(status) + mr.Status = model.GitusRepositoryStatus(status) mr.ForkOriginNamespace = originNamespace mr.ForkOriginName = originName mr.RepoLabelList = tags @@ -2366,7 +2366,7 @@ WHERE repo_owner = ? AND repo_fork_origin_namespace = ? AND repo_fork_origin_nam return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllPullRequestPaginated(namespace string, name string, pageNum int64, pageSize int64) ([]*model.PullRequest, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllPullRequestPaginated(namespace string, name string, pageNum int64, pageSize int64) ([]*model.PullRequest, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT rowid, pull_request_id, username, title, receiver_branch, provider_namespace, provider_name, provider_branch, merge_conflict_check_result, merge_conflict_check_timestamp, pull_request_status, pull_request_timestamp @@ -2412,7 +2412,7 @@ ORDER BY pull_request_id ASC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountIssue(query string, namespace string, name string, filterType int) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountIssue(query string, namespace string, name string, filterType int) (int64, error) { pfx := dbif.config.Database.TablePrefix statusClause := "" switch filterType { @@ -2456,7 +2456,7 @@ SELECT COUNT(*) FROM %s_issue %s return cnt, nil } -func (dbif *SqliteAegisDatabaseInterface) SearchIssuePaginated(query string, namespace string, name string, filterType int, pageNum int64, pageSize int64) ([]*model.Issue, error) { +func (dbif *SqliteGitusDatabaseInterface) SearchIssuePaginated(query string, namespace string, name string, filterType int, pageNum int64, pageSize int64) ([]*model.Issue, error) { pfx := dbif.config.Database.TablePrefix statusClause := "" switch filterType { @@ -2507,7 +2507,7 @@ ORDER BY issue_priority DESC, issue_timestamp DESC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) NewPullRequest(username string, title string, receiverNamespace string, receiverName string, receiverBranch string, providerNamespace string, providerName string, providerBranch string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) NewPullRequest(username string, title string, receiverNamespace string, receiverName string, receiverBranch string, providerNamespace string, providerName string, providerBranch string) (int64, error) { pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT COUNT(*) FROM %spull_request @@ -2544,7 +2544,7 @@ INSERT INTO %spull_request( return newid, nil } -func (dbif *SqliteAegisDatabaseInterface) GetPullRequest(namespace string, name string, id int64) (*model.PullRequest, error) { +func (dbif *SqliteGitusDatabaseInterface) GetPullRequest(namespace string, name string, id int64) (*model.PullRequest, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT rowid, username, title, receiver_branch, provider_namespace, provider_name, provider_branch, merge_conflict_check_result, merge_conflict_check_timestamp, pull_request_status, pull_request_timestamp @@ -2584,7 +2584,7 @@ WHERE receiver_namespace = ? AND receiver_name = ? AND pull_request_id = ? }, nil } -func (dbif *SqliteAegisDatabaseInterface) GetPullRequestByAbsId(absId int64) (*model.PullRequest, error) { +func (dbif *SqliteGitusDatabaseInterface) GetPullRequestByAbsId(absId int64) (*model.PullRequest, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT username, pull_request_id, title, receiver_namespace, receiver_name, receiver_branch, provider_namespace, provider_name, provider_branch, merge_conflict_check_result, merge_conflict_check_timestamp, pull_request_status, pull_request_timestamp @@ -2621,7 +2621,7 @@ WHERE rowid = ? }, nil } -func (dbif *SqliteAegisDatabaseInterface) CheckPullRequestMergeConflict(absId int64) (*gitlib.MergeCheckResult, error) { +func (dbif *SqliteGitusDatabaseInterface) CheckPullRequestMergeConflict(absId int64) (*gitlib.MergeCheckResult, error) { // WARNING: currently only works when when the source & // the target is git repo. currently (2025.7.28) this check // is performed at the controller side, i.e. users cannot @@ -2665,7 +2665,7 @@ WHERE rowid = ? return mr, nil } -func (dbif *SqliteAegisDatabaseInterface) DeletePullRequest(absId int64) error { +func (dbif *SqliteGitusDatabaseInterface) DeletePullRequest(absId int64) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -2681,7 +2681,7 @@ DELETE FROM %spull_request WHERE rowid = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllPullRequestEventPaginated(absId int64, pageNum int64, pageSize int64) ([]*model.PullRequestEvent, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllPullRequestEventPaginated(absId int64, pageNum int64, pageSize int64) ([]*model.PullRequestEvent, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT event_type, event_timestamp, event_author, event_content @@ -2710,7 +2710,7 @@ ORDER BY event_timestamp ASC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CheckAndMergePullRequest(absId int64, username string) error { +func (dbif *SqliteGitusDatabaseInterface) CheckAndMergePullRequest(absId int64, username string) error { // WARNING: currently only works when when the source & // the target is git repo. currently (2025.7.28) this check // is performed at the controller side, i.e. users cannot @@ -2789,7 +2789,7 @@ VALUES (?,?,?,?,?) return nil } -func (dbif *SqliteAegisDatabaseInterface) CommentOnPullRequest(absId int64, author string, content string) (*model.PullRequestEvent, error) { +func (dbif *SqliteGitusDatabaseInterface) CommentOnPullRequest(absId int64, author string, content string) (*model.PullRequestEvent, error) { pfx := dbif.config.Database.TablePrefix t := time.Now().Unix() tx, err := dbif.connection.Begin() @@ -2813,7 +2813,7 @@ INSERT INTO %spull_request_event(pull_request_abs_id, event_type, event_timestam }, nil } -func (dbif *SqliteAegisDatabaseInterface) CommentOnPullRequestCode(absId int64, comment *model.PullRequestCommentOnCode) (*model.PullRequestEvent, error) { +func (dbif *SqliteGitusDatabaseInterface) CommentOnPullRequestCode(absId int64, comment *model.PullRequestCommentOnCode) (*model.PullRequestEvent, error) { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return nil, err } @@ -2839,7 +2839,7 @@ VALUES (?,?,?,?,?) }, nil } -func (dbif *SqliteAegisDatabaseInterface) ClosePullRequestAsNotMerged(absid int64, author string) error { +func (dbif *SqliteGitusDatabaseInterface) ClosePullRequestAsNotMerged(absid int64, author string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -2865,7 +2865,7 @@ WHERE rowid = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) ReopenPullRequest(absid int64, author string) error { +func (dbif *SqliteGitusDatabaseInterface) ReopenPullRequest(absid int64, author string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -2891,7 +2891,7 @@ WHERE rowid = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) CountPullRequest(query string, namespace string, name string, filterType int) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountPullRequest(query string, namespace string, name string, filterType int) (int64, error) { pfx := dbif.config.Database.TablePrefix statusClause := "" switch filterType { @@ -2920,7 +2920,7 @@ WHERE receiver_namespace = ? AND receiver_name = ? %s %s return res, nil } -func (dbif *SqliteAegisDatabaseInterface) SearchPullRequestPaginated(query string, namespace string, name string, filterType int, pageNum int64, pageSize int64) ([]*model.PullRequest, error) { +func (dbif *SqliteGitusDatabaseInterface) SearchPullRequestPaginated(query string, namespace string, name string, filterType int, pageNum int64, pageSize int64) ([]*model.PullRequest, error) { pfx := dbif.config.Database.TablePrefix statusClause := "" switch filterType { @@ -2982,7 +2982,7 @@ ORDER BY pull_request_timestamp DESC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllRegisteredEmailOfUser(username string) ([]struct{Email string;Verified bool}, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllRegisteredEmailOfUser(username string) ([]struct{Email string;Verified bool}, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT email, verified FROM %s_user_email WHERE username = ? @@ -3005,7 +3005,7 @@ SELECT email, verified FROM %s_user_email WHERE username = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) AddEmail(username string, email string) error { +func (dbif *SqliteGitusDatabaseInterface) AddEmail(username string, email string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -3021,7 +3021,7 @@ INSERT INTO %s_user_email(username, email, verified) VALUES (?, ?, 0) return nil } -func (dbif *SqliteAegisDatabaseInterface) VerifyRegisteredEmail(username string, email string) error { +func (dbif *SqliteGitusDatabaseInterface) VerifyRegisteredEmail(username string, email string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -3037,7 +3037,7 @@ UPDATE %s_user_email SET verified = 1 WHERE username = ? AND email = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) DeleteRegisteredEmail(username string, email string) error { +func (dbif *SqliteGitusDatabaseInterface) DeleteRegisteredEmail(username string, email string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -3053,7 +3053,7 @@ DELETE FROM %s_user_email WHERE username = ? AND email = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) CheckIfEmailVerified(username string, email string) (bool, error) { +func (dbif *SqliteGitusDatabaseInterface) CheckIfEmailVerified(username string, email string) (bool, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT verified FROM %s_user_email WHERE username = ? AND email = ? @@ -3067,7 +3067,7 @@ SELECT verified FROM %s_user_email WHERE username = ? AND email = ? return r == 1, nil } -func (dbif *SqliteAegisDatabaseInterface) ResolveEmailToUsername(email string) (string, error) { +func (dbif *SqliteGitusDatabaseInterface) ResolveEmailToUsername(email string) (string, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT username FROM %s_user_email WHERE email = ? AND verified = 1 @@ -3082,7 +3082,7 @@ SELECT username FROM %s_user_email WHERE email = ? AND verified = 1 return r, nil } -func (dbif *SqliteAegisDatabaseInterface) ResolveMultipleEmailToUsername(emailList map[string]string) (map[string]string, error) { +func (dbif *SqliteGitusDatabaseInterface) ResolveMultipleEmailToUsername(emailList map[string]string) (map[string]string, error) { pfx := dbif.config.Database.TablePrefix l := make([]any, 0) q := make([]string, 0) @@ -3109,7 +3109,7 @@ SELECT email, username FROM %s_user_email WHERE verified = 1 AND email IN (%s) return emailList, nil } -func (dbif *SqliteAegisDatabaseInterface) InsertRegistrationRequest(username string, email string, passwordHash string, reason string) error { +func (dbif *SqliteGitusDatabaseInterface) InsertRegistrationRequest(username string, email string, passwordHash string, reason string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -3125,7 +3125,7 @@ INSERT INTO %s_user_reg_request(username, email, password_hash, reason, timestam return nil } -func (dbif *SqliteAegisDatabaseInterface) ApproveRegistrationRequest(absid int64) error { +func (dbif *SqliteGitusDatabaseInterface) ApproveRegistrationRequest(absid int64) error { pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT username, email, password_hash FROM %s_user_reg_request @@ -3160,7 +3160,7 @@ DELETE FROM %s_user_reg_request WHERE username = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) DisapproveRegistrationRequest(absid int64) error { +func (dbif *SqliteGitusDatabaseInterface) DisapproveRegistrationRequest(absid int64) error { pfx := dbif.config.Database.TablePrefix stmt1, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT username FROM %s_user_reg_request @@ -3188,7 +3188,7 @@ DELETE FROM %s_user_reg_request WHERE username = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) GetRegistrationRequestPaginated(pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { +func (dbif *SqliteGitusDatabaseInterface) GetRegistrationRequestPaginated(pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT username, email, password_hash, reason, timestamp @@ -3217,7 +3217,7 @@ ORDER BY timestamp DESC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetRequestOfUsernamePaginated(username string, pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { +func (dbif *SqliteGitusDatabaseInterface) GetRequestOfUsernamePaginated(username string, pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT rowid, email, password_hash, reason, timestamp @@ -3248,7 +3248,7 @@ ORDER BY timestamp DESC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountRegistrationRequest(query string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountRegistrationRequest(query string) (int64, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Row query = strings.TrimSpace(query) @@ -3273,7 +3273,7 @@ SELECT COUNT(*) FROM %s_user_reg_request WHERE username LIKE ? ESCAPE ? return cnt, nil } -func (dbif *SqliteAegisDatabaseInterface) SearchRegistrationRequestPaginated(query string, pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { +func (dbif *SqliteGitusDatabaseInterface) SearchRegistrationRequestPaginated(query string, pageNum int64, pageSize int64) ([]*model.RegistrationRequest, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Rows query = strings.TrimSpace(query) @@ -3311,7 +3311,7 @@ SELECT rowid, username, email, password_hash, timestamp FROM %s_user_reg_request return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetRegistrationRequestByAbsId(absid int64) (*model.RegistrationRequest, error) { +func (dbif *SqliteGitusDatabaseInterface) GetRegistrationRequestByAbsId(absid int64) (*model.RegistrationRequest, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT rowid, username, email, password_hash, timestamp FROM %s_user_reg_request WHERE rowid = ? @@ -3332,7 +3332,7 @@ SELECT rowid, username, email, password_hash, timestamp FROM %s_user_reg_request }, nil } -func (dbif *SqliteAegisDatabaseInterface) AddRepositoryLabel(ns string, name string, lbl string) error { +func (dbif *SqliteGitusDatabaseInterface) AddRepositoryLabel(ns string, name string, lbl string) error { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT repo_label_list FROM %s_repository WHERE repo_namespace = ? and repo_name = ? @@ -3365,7 +3365,7 @@ UPDATE %s_repository SET repo_label_list = ? WHERE repo_namespace = ? AND repo_n return nil } -func (dbif *SqliteAegisDatabaseInterface) RemoveRepositoryLabel(ns string, name string, lbl string) error { +func (dbif *SqliteGitusDatabaseInterface) RemoveRepositoryLabel(ns string, name string, lbl string) error { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT repo_label_list FROM %s_repository WHERE repo_namespace = ? AND repo_name = ? @@ -3394,7 +3394,7 @@ UPDATE %s_repository SET repo_label_list = ? WHERE repo_namespace = ? AND repo_n return nil } -func (dbif *SqliteAegisDatabaseInterface) GetRepositoryLabel(ns string, name string) ([]string, error) { +func (dbif *SqliteGitusDatabaseInterface) GetRepositoryLabel(ns string, name string) ([]string, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT repo_label_list FROM %s_repository WHERE repo_namespace = ? and repo_name = ? @@ -3409,7 +3409,7 @@ SELECT repo_label_list FROM %s_repository WHERE repo_namespace = ? and repo_name return tags, nil } -func (dbif *SqliteAegisDatabaseInterface) CountRepositoryWithLabel(username string, label string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountRepositoryWithLabel(username string, label string) (int64, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Row var err error @@ -3440,7 +3440,7 @@ AND ( return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetRepositoryWithLabelPaginated(username string, label string, pageNum int64, pageSize int64) ([]*model.Repository, error) { +func (dbif *SqliteGitusDatabaseInterface) GetRepositoryWithLabelPaginated(username string, label string, pageNum int64, pageSize int64) ([]*model.Repository, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Rows var err error @@ -3493,7 +3493,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? Owner: owner, Description: desc, AccessControlList: a, - Status: model.AegisRepositoryStatus(status), + Status: model.GitusRepositoryStatus(status), Repository: gitlib.NewLocalGitRepository(p), ForkOriginNamespace: forkOriginNs, ForkOriginName: forkOriginName, @@ -3503,7 +3503,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) NewSnippet(username string, name string, status uint8) (*model.Snippet, error) { +func (dbif *SqliteGitusDatabaseInterface) NewSnippet(username string, name string, status uint8) (*model.Snippet, error) { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return nil, err } @@ -3536,7 +3536,7 @@ VALUES (?,?,?,?,?,?,?) }, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllSnippet(username string) ([]*model.Snippet, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllSnippet(username string) ([]*model.Snippet, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT name, description, timestamp, status, shared_user @@ -3570,7 +3570,7 @@ WHERE username = ? return res, nil } -func (dbif *SqliteAegisDatabaseInterface) CountAllVisibleSnippet(username string, viewingUser string, query string) (int64, error) { +func (dbif *SqliteGitusDatabaseInterface) CountAllVisibleSnippet(username string, viewingUser string, query string) (int64, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Row var err error @@ -3630,7 +3630,7 @@ WHERE username = ? AND (status = 1 OR status = 2 OR (status = 4 AND shared_user return res, nil } -func (dbif *SqliteAegisDatabaseInterface) GetAllVisibleSnippetPaginated(username string, viewingUser string, query string, pageNum int64, pageSize int64) ([]*model.Snippet, error) { +func (dbif *SqliteGitusDatabaseInterface) GetAllVisibleSnippetPaginated(username string, viewingUser string, query string, pageNum int64, pageSize int64) ([]*model.Snippet, error) { pfx := dbif.config.Database.TablePrefix var r *sql.Rows var err error @@ -3715,7 +3715,7 @@ WHERE username = ? AND (status = 1 OR status = 2 OR (status = 4 AND shared_user return res, nil } -func (dbif *SqliteAegisDatabaseInterface) DeleteSnippet(username string, name string) error { +func (dbif *SqliteGitusDatabaseInterface) DeleteSnippet(username string, name string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -3734,7 +3734,7 @@ DELETE FROM %s_snippet WHERE username = ? AND name = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) SaveSnippetInfo(m *model.Snippet) error { +func (dbif *SqliteGitusDatabaseInterface) SaveSnippetInfo(m *model.Snippet) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -3752,7 +3752,7 @@ UPDATE %s_snippet SET description = ?, status = ?, shared_user = ? WHERE usernam return nil } -func (dbif *SqliteAegisDatabaseInterface) GetSnippet(username string, name string) (*model.Snippet, error) { +func (dbif *SqliteGitusDatabaseInterface) GetSnippet(username string, name string) (*model.Snippet, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT description, timestamp, status, shared_user FROM %s_snippet @@ -3780,7 +3780,7 @@ WHERE username = ? AND name = ? }, nil } -func (dbif *SqliteAegisDatabaseInterface) RegisterWebhookRequest(uuid string, reportUuid string, repoNs string, repoName string, commitId string) error { +func (dbif *SqliteGitusDatabaseInterface) RegisterWebhookRequest(uuid string, reportUuid string, repoNs string, repoName string, commitId string) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -3805,7 +3805,7 @@ VALUES (?,?,?,?,?) return nil } -func (dbif *SqliteAegisDatabaseInterface) UpdateWebhookResult(uuid string, result *model.WebhookResult) error { +func (dbif *SqliteGitusDatabaseInterface) UpdateWebhookResult(uuid string, result *model.WebhookResult) error { pfx := dbif.config.Database.TablePrefix tx, err := dbif.connection.Begin() if err != nil { return err } @@ -3823,7 +3823,7 @@ UPDATE %s_webhook_log SET webhook_result = ? WHERE uuid = ? return nil } -func (dbif *SqliteAegisDatabaseInterface) GetWebhookResultByUUID(uuid string) (*model.WebhookResult, error) { +func (dbif *SqliteGitusDatabaseInterface) GetWebhookResultByUUID(uuid string) (*model.WebhookResult, error) { pfx := dbif.config.Database.TablePrefix stmt, err := dbif.connection.Prepare(fmt.Sprintf(` SELECT webhook_result FROM %s_webhook_log diff --git a/pkg/aegis/log/main.go b/pkg/gitus/log/main.go similarity index 100% rename from pkg/aegis/log/main.go rename to pkg/gitus/log/main.go diff --git a/pkg/aegis/mail/gmail_plain/main.go b/pkg/gitus/mail/gmail_plain/main.go similarity index 74% rename from pkg/aegis/mail/gmail_plain/main.go rename to pkg/gitus/mail/gmail_plain/main.go index c3fecc9..ce0713f 100644 --- a/pkg/aegis/mail/gmail_plain/main.go +++ b/pkg/gitus/mail/gmail_plain/main.go @@ -4,23 +4,23 @@ import ( gomail "github.com/wneessen/go-mail" ) -type AegisGmailPlainMailerInterface struct { +type GitusGmailPlainMailerInterface struct { username string appPassword string client *gomail.Client } -func NewAegisGmailPlainMailerInterface(username string, appPassword string) (*AegisGmailPlainMailerInterface, error) { +func NewGitusGmailPlainMailerInterface(username string, appPassword string) (*GitusGmailPlainMailerInterface, error) { cl, err := gomail.NewClient("smtp.gmail.com", gomail.WithPort(587), gomail.WithSMTPAuth(gomail.SMTPAuthPlain), gomail.WithUsername(username), gomail.WithPassword(appPassword)) if err != nil { return nil, err } - return &AegisGmailPlainMailerInterface{ + return &GitusGmailPlainMailerInterface{ username: username, appPassword: appPassword, client: cl, }, nil } -func (mi *AegisGmailPlainMailerInterface) SendPlainTextMail(target string, title string, body string) error { +func (mi *GitusGmailPlainMailerInterface) SendPlainTextMail(target string, title string, body string) error { msg := gomail.NewMsg() if err := msg.From(mi.username); err != nil { return err } if err := msg.To(target); err != nil { return err } @@ -29,7 +29,7 @@ func (mi *AegisGmailPlainMailerInterface) SendPlainTextMail(target string, title return mi.client.DialAndSend(msg) } -func (mi *AegisGmailPlainMailerInterface) SendHTMLMail(target string, title string, body string) error { +func (mi *GitusGmailPlainMailerInterface) SendHTMLMail(target string, title string, body string) error { msg := gomail.NewMsg() if err := msg.From(mi.username); err != nil { return err } if err := msg.To(target); err != nil { return err } diff --git a/pkg/gitus/mail/mailif.go b/pkg/gitus/mail/mailif.go new file mode 100644 index 0000000..ddf1f39 --- /dev/null +++ b/pkg/gitus/mail/mailif.go @@ -0,0 +1,32 @@ +package mail + +import ( + "errors" + + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/mail/gmail_plain" + "github.com/GitusCodeForge/Gitus/pkg/gitus/mail/smtp_plain" +) + +type GitusMailerInterface interface { + SendPlainTextMail(target string, title string, body string) error + SendHTMLMail(target string, title string, body string) error +} + +var ErrNotSupported = errors.New("Type not supported.") + +func InitializeMailer(cfg *gitus.GitusConfig) (GitusMailerInterface, error) { + return CreateMailerFromMailerConfig(&cfg.Mailer) +} + +func CreateMailerFromMailerConfig(cfg *gitus.GitusMailerConfig) (GitusMailerInterface, error) { + switch cfg.Type { + case "gmail-plain": + return gmail_plain.NewGitusGmailPlainMailerInterface(cfg.User, cfg.Password) + case "smtp": + return smtp_plain.NewGitusSMTPPlainMailerInterface(cfg.SMTPServer, cfg.SMTPPort, cfg.SMTPAuth, cfg.User, cfg.Password) + } + return nil, ErrNotSupported +} + + diff --git a/pkg/aegis/mail/smtp_plain/main.go b/pkg/gitus/mail/smtp_plain/main.go similarity index 76% rename from pkg/aegis/mail/smtp_plain/main.go rename to pkg/gitus/mail/smtp_plain/main.go index 0b05393..904038b 100644 --- a/pkg/aegis/mail/smtp_plain/main.go +++ b/pkg/gitus/mail/smtp_plain/main.go @@ -4,25 +4,25 @@ import ( gomail "github.com/wneessen/go-mail" ) -type AegisSMTPPlainMailerInterface struct { +type GitusSMTPPlainMailerInterface struct { username string appPassword string client *gomail.Client } -func NewAegisSMTPPlainMailerInterface(host string, port int, auth string, username string, appPassword string) (*AegisSMTPPlainMailerInterface, error) { +func NewGitusSMTPPlainMailerInterface(host string, port int, auth string, username string, appPassword string) (*GitusSMTPPlainMailerInterface, error) { authType := gomail.SMTPAuthAutoDiscover if len(auth) > 0 { authType = gomail.SMTPAuthType(auth) } cl, err := gomail.NewClient(host, gomail.WithPort(port), gomail.WithSMTPAuth(authType), gomail.WithUsername(username), gomail.WithPassword(appPassword)) if err != nil { return nil, err } - return &AegisSMTPPlainMailerInterface{ + return &GitusSMTPPlainMailerInterface{ username: username, appPassword: appPassword, client: cl, }, nil } -func (mi *AegisSMTPPlainMailerInterface) SendPlainTextMail(target string, title string, body string) error { +func (mi *GitusSMTPPlainMailerInterface) SendPlainTextMail(target string, title string, body string) error { msg := gomail.NewMsg() if err := msg.From(mi.username); err != nil { return err } if err := msg.To(target); err != nil { return err } @@ -31,7 +31,7 @@ func (mi *AegisSMTPPlainMailerInterface) SendPlainTextMail(target string, title return mi.client.DialAndSend(msg) } -func (mi *AegisSMTPPlainMailerInterface) SendHTMLMail(target string, title string, body string) error { +func (mi *GitusSMTPPlainMailerInterface) SendHTMLMail(target string, title string, body string) error { msg := gomail.NewMsg() if err := msg.From(mi.username); err != nil { return err } if err := msg.To(target); err != nil { return err } diff --git a/pkg/aegis/model/acl.go b/pkg/gitus/model/acl.go similarity index 100% rename from pkg/aegis/model/acl.go rename to pkg/gitus/model/acl.go diff --git a/pkg/aegis/model/issue.go b/pkg/gitus/model/issue.go similarity index 100% rename from pkg/aegis/model/issue.go rename to pkg/gitus/model/issue.go diff --git a/pkg/aegis/model/keys.go b/pkg/gitus/model/keys.go similarity index 79% rename from pkg/aegis/model/keys.go rename to pkg/gitus/model/keys.go index 72f0add..9a97a07 100644 --- a/pkg/aegis/model/keys.go +++ b/pkg/gitus/model/keys.go @@ -1,12 +1,12 @@ package model -type AegisSigningKey struct { +type GitusSigningKey struct { UserName string `json:"userName"` KeyName string `json:"keyName"` KeyText string `json:"keyText"` } -type AegisAuthKey struct { +type GitusAuthKey struct { UserName string `json:"userName"` KeyName string `json:"keyName"` KeyText string `json:"keyText"` diff --git a/pkg/aegis/model/localrepo.go b/pkg/gitus/model/localrepo.go similarity index 93% rename from pkg/aegis/model/localrepo.go rename to pkg/gitus/model/localrepo.go index 69c9a5f..dcb9953 100644 --- a/pkg/aegis/model/localrepo.go +++ b/pkg/gitus/model/localrepo.go @@ -10,14 +10,14 @@ import ( "os/user" "strconv" - "github.com/bctnry/aegis/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" ) type LocalRepository any var ErrNotSupported = errors.New("Not supported type of local repository.") -func GetAegisType(x LocalRepository) uint8 { +func GetGitusType(x LocalRepository) uint8 { _, ok := x.(*gitlib.LocalGitRepository) if ok { return REPO_TYPE_GIT } return 0 @@ -33,7 +33,7 @@ func CreateLocalRepository(repoType uint8, namespace string, name string, dirPat } func InitLocalRepository(lr LocalRepository) error { - switch GetAegisType(lr) { + switch GetGitusType(lr) { case REPO_TYPE_GIT: cmd := exec.Command("git", "init", "--bare") cmd.Dir = GetLocalRepositoryLocalPath(lr) @@ -44,7 +44,7 @@ func InitLocalRepository(lr LocalRepository) error { } func CreateLocalForkOf(origin LocalRepository, newNs string, newName string, newP string) (LocalRepository, error) { - switch GetAegisType(origin) { + switch GetGitusType(origin) { case REPO_TYPE_GIT: err := origin.(*gitlib.LocalGitRepository).LocalForkTo(fmt.Sprintf("%s/%s", newNs, newName), newP) if err != nil { return nil, err } @@ -55,7 +55,7 @@ func CreateLocalForkOf(origin LocalRepository, newNs string, newName string, new } func GetLocalRepositoryLocalPath(r LocalRepository) string { - switch GetAegisType(r) { + switch GetGitusType(r) { case REPO_TYPE_GIT: return r.(*gitlib.LocalGitRepository).GitDirectoryPath default: @@ -72,7 +72,7 @@ func AddFileToRepoString( commitMessage string, content string, ) (string, error) { - switch GetAegisType(lr) { + switch GetGitusType(lr) { case REPO_TYPE_GIT: glr := lr.(*gitlib.LocalGitRepository) return glr.AddFileToRepoString( @@ -95,7 +95,7 @@ func AddFileToRepoReader( commitMessage string, content io.Reader, contentSize int64, ) (string, error) { - switch GetAegisType(lr) { + switch GetGitusType(lr) { case REPO_TYPE_GIT: glr := lr.(*gitlib.LocalGitRepository) return glr.AddFileToRepoReader( @@ -118,7 +118,7 @@ func AddMultipleFileToRepoString( commitMessage string, content map[string]string, ) (string, error) { - switch GetAegisType(lr) { + switch GetGitusType(lr) { case REPO_TYPE_GIT: glr := lr.(*gitlib.LocalGitRepository) return glr.AddMultipleFileToRepoString( diff --git a/pkg/aegis/model/namespace.go b/pkg/gitus/model/namespace.go similarity index 89% rename from pkg/aegis/model/namespace.go rename to pkg/gitus/model/namespace.go index 6aa6e63..7e793be 100644 --- a/pkg/aegis/model/namespace.go +++ b/pkg/gitus/model/namespace.go @@ -6,15 +6,15 @@ import ( "path" "strings" - "github.com/bctnry/aegis/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" ) -type AegisNamespaceStatus int +type GitusNamespaceStatus int const ( - NAMESPACE_NORMAL_PUBLIC AegisNamespaceStatus = 1 - NAMESPACE_NORMAL_PRIVATE AegisNamespaceStatus = 2 - NAMESPACE_INTERNAL AegisNamespaceStatus = 3 + NAMESPACE_NORMAL_PUBLIC GitusNamespaceStatus = 1 + NAMESPACE_NORMAL_PRIVATE GitusNamespaceStatus = 2 + NAMESPACE_INTERNAL GitusNamespaceStatus = 3 ) type Namespace struct { @@ -28,7 +28,7 @@ type Namespace struct { Email string `json:"email"` Owner string `json:"owner"` RegisterTime int64 `json:"regTime"` - Status AegisNamespaceStatus `json:"status"` + Status GitusNamespaceStatus `json:"status"` ACL *ACL RepositoryList map[string]*Repository `json:"repoList"` LocalPath string `json:"localPath"` diff --git a/pkg/aegis/model/pull_request.go b/pkg/gitus/model/pull_request.go similarity index 97% rename from pkg/aegis/model/pull_request.go rename to pkg/gitus/model/pull_request.go index 5edcdf6..1ad4ba5 100644 --- a/pkg/aegis/model/pull_request.go +++ b/pkg/gitus/model/pull_request.go @@ -1,6 +1,6 @@ package model -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" const ( PULL_REQUEST_OPEN = 1 diff --git a/pkg/aegis/model/registration_request.go b/pkg/gitus/model/registration_request.go similarity index 100% rename from pkg/aegis/model/registration_request.go rename to pkg/gitus/model/registration_request.go diff --git a/pkg/aegis/model/repository.go b/pkg/gitus/model/repository.go similarity index 88% rename from pkg/aegis/model/repository.go rename to pkg/gitus/model/repository.go index 5a15967..81f8f53 100644 --- a/pkg/aegis/model/repository.go +++ b/pkg/gitus/model/repository.go @@ -5,17 +5,17 @@ import ( "fmt" "path" - "github.com/bctnry/aegis/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" ) -type AegisRepositoryStatus int +type GitusRepositoryStatus int const ( - REPO_NORMAL_PUBLIC AegisRepositoryStatus = 1 - REPO_NORMAL_PRIVATE AegisRepositoryStatus = 2 - REPO_ARCHIVED AegisRepositoryStatus = 4 - REPO_INTERNAL AegisRepositoryStatus = 5 - REPO_LIMITED AegisRepositoryStatus = 6 + REPO_NORMAL_PUBLIC GitusRepositoryStatus = 1 + REPO_NORMAL_PRIVATE GitusRepositoryStatus = 2 + REPO_ARCHIVED GitusRepositoryStatus = 4 + REPO_INTERNAL GitusRepositoryStatus = 5 + REPO_LIMITED GitusRepositoryStatus = 6 ) const ( @@ -56,7 +56,7 @@ type Repository struct { Description string `json:"description"` AccessControlList *ACL `json:"acl"` Owner string `json:"owner"` - Status AegisRepositoryStatus `json:"status"` + Status GitusRepositoryStatus `json:"status"` Repository LocalRepository LocalPath string `json:"localPath"` ForkOriginNamespace string `json:"forkOriginNamespace"` diff --git a/pkg/aegis/model/simple_mode_config.go b/pkg/gitus/model/simple_mode_config.go similarity index 100% rename from pkg/aegis/model/simple_mode_config.go rename to pkg/gitus/model/simple_mode_config.go diff --git a/pkg/aegis/model/snippet.go b/pkg/gitus/model/snippet.go similarity index 100% rename from pkg/aegis/model/snippet.go rename to pkg/gitus/model/snippet.go diff --git a/pkg/aegis/model/user.go b/pkg/gitus/model/user.go similarity index 60% rename from pkg/aegis/model/user.go rename to pkg/gitus/model/user.go index 4628f12..8bda844 100644 --- a/pkg/aegis/model/user.go +++ b/pkg/gitus/model/user.go @@ -1,15 +1,15 @@ package model -type AegisUserStatus int +type GitusUserStatus int const ( - NORMAL_USER AegisUserStatus = 1 - NORMAL_USER_APPROVAL_NEEDED AegisUserStatus = 2 - NORMAL_USER_CONFIRM_NEEDED AegisUserStatus = 3 - ADMIN AegisUserStatus = 4 - SUPER_ADMIN AegisUserStatus = 5 - BANNED AegisUserStatus = 7 - NORMAL_USER_NO_NEW_NAMESPACE AegisUserStatus = 8 + NORMAL_USER GitusUserStatus = 1 + NORMAL_USER_APPROVAL_NEEDED GitusUserStatus = 2 + NORMAL_USER_CONFIRM_NEEDED GitusUserStatus = 3 + ADMIN GitusUserStatus = 4 + SUPER_ADMIN GitusUserStatus = 5 + BANNED GitusUserStatus = 7 + NORMAL_USER_NO_NEW_NAMESPACE GitusUserStatus = 8 ) func ValidUserName(s string) bool { @@ -19,7 +19,7 @@ func ValidUserName(s string) bool { return true } -type AegisUser struct { +type GitusUser struct { // user name. Name string `json:"name"` // user "title" @@ -32,21 +32,21 @@ type AegisUser struct { // password hash. PasswordHash string `json:"passwordHash"` RegisterTime int64 `json:"regTime"` - Status AegisUserStatus `json:"status"` - // AuthKey []AegisAuthKey `json:"authKey"` - // SigningKey []AegisSigningKey `json:"signKey"` + Status GitusUserStatus `json:"status"` + // AuthKey []GitusAuthKey `json:"authKey"` + // SigningKey []GitusSigningKey `json:"signKey"` - TFAConfig AegisUser2FAConfig `json:"2fa"` - WebsitePreference AegisUserWebsitePreference `json:"preference"` + TFAConfig GitusUser2FAConfig `json:"2fa"` + WebsitePreference GitusUserWebsitePreference `json:"preference"` } -type AegisUser2FAConfig struct { +type GitusUser2FAConfig struct { Email struct{ Enable bool `json:"enable"` } `json:"email"` } -type AegisUserWebsitePreference struct { +type GitusUserWebsitePreference struct { ForegroundColor string `json:"foregroundColor"` BackgroundColor string `json:"backgroundColor"` // ignore user custom fgcolor/bgcolor config if true. diff --git a/pkg/aegis/model/webhookresult.go b/pkg/gitus/model/webhookresult.go similarity index 100% rename from pkg/aegis/model/webhookresult.go rename to pkg/gitus/model/webhookresult.go diff --git a/pkg/aegis/receipt/#rserr.go# b/pkg/gitus/receipt/#rserr.go# similarity index 100% rename from pkg/aegis/receipt/#rserr.go# rename to pkg/gitus/receipt/#rserr.go# diff --git a/pkg/gitus/receipt/init/main.go b/pkg/gitus/receipt/init/main.go new file mode 100644 index 0000000..1f8e1f8 --- /dev/null +++ b/pkg/gitus/receipt/init/main.go @@ -0,0 +1,17 @@ +package init + +import ( + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt/sqlite" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt/postgres" +) + +func InitializeReceiptSystem(cfg *gitus.GitusConfig) (receipt.GitusReceiptSystemInterface, error) { + switch cfg.ReceiptSystem.Type { + case "sqlite": return sqlite.NewSqliteReceiptSystemInterface(cfg) + case "postgres": return postgres.NewPostgresReceiptSystemInterface(cfg) + } + return nil, receipt.ErrUnsupportedSystemType +} + diff --git a/pkg/aegis/receipt/postgres/main.go b/pkg/gitus/receipt/postgres/main.go similarity index 85% rename from pkg/aegis/receipt/postgres/main.go rename to pkg/gitus/receipt/postgres/main.go index 0b3a465..7e0bbee 100644 --- a/pkg/aegis/receipt/postgres/main.go +++ b/pkg/gitus/receipt/postgres/main.go @@ -8,14 +8,14 @@ import ( "strings" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/receipt" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" ) -type AegisPostgresReceiptSystemInterface struct { - config *aegis.AegisConfig +type GitusPostgresReceiptSystemInterface struct { + config *gitus.GitusConfig pool *pgxpool.Pool } @@ -23,7 +23,7 @@ var requiredTableList = []string{ "receipt", } -func NewPostgresReceiptSystemInterface(cfg *aegis.AegisConfig) (*AegisPostgresReceiptSystemInterface, error) { +func NewPostgresReceiptSystemInterface(cfg *gitus.GitusConfig) (*GitusPostgresReceiptSystemInterface, error) { u := &url.URL{ Scheme: "postgres", User: url.UserPassword(cfg.Database.UserName, cfg.Database.Password), @@ -32,18 +32,18 @@ func NewPostgresReceiptSystemInterface(cfg *aegis.AegisConfig) (*AegisPostgresRe } pool, err := pgxpool.New(context.TODO(), u.String()) if err != nil { return nil, err } - return &AegisPostgresReceiptSystemInterface{ + return &GitusPostgresReceiptSystemInterface{ config: cfg, pool: pool, }, nil } -func (rsif *AegisPostgresReceiptSystemInterface) Dispose() error { +func (rsif *GitusPostgresReceiptSystemInterface) Dispose() error { rsif.pool.Close() return nil } -func (rsif *AegisPostgresReceiptSystemInterface) IsReceiptSystemUsable() (bool, error) { +func (rsif *GitusPostgresReceiptSystemInterface) IsReceiptSystemUsable() (bool, error) { ctx := context.Background() queryStr := ` SELECT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = $1) @@ -60,7 +60,7 @@ SELECT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = return true, nil } -func (rsif *AegisPostgresReceiptSystemInterface) Install() error { +func (rsif *GitusPostgresReceiptSystemInterface) Install() error { pfx := rsif.config.ReceiptSystem.TablePrefix ctx := context.Background() tx, err := rsif.pool.Begin(ctx) @@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS %s_receipt ( return nil } -func (rsif *AegisPostgresReceiptSystemInterface) RetrieveReceipt(rid string) (*receipt.Receipt, error) { +func (rsif *GitusPostgresReceiptSystemInterface) RetrieveReceipt(rid string) (*receipt.Receipt, error) { pfx := rsif.config.ReceiptSystem.TablePrefix ctx := context.Background() stmt := rsif.pool.QueryRow(ctx, fmt.Sprintf(` @@ -100,7 +100,7 @@ WHERE id = $1 }, nil } -func (rsif *AegisPostgresReceiptSystemInterface) IssueReceipt(timeoutMinute int64, command []string) (string, error) { +func (rsif *GitusPostgresReceiptSystemInterface) IssueReceipt(timeoutMinute int64, command []string) (string, error) { pfx := rsif.config.ReceiptSystem.TablePrefix ctx := context.Background() tx, err := rsif.pool.Begin(ctx) @@ -117,7 +117,7 @@ VALUES ($1,$2,$3,$4) return rid, nil } -func (rsif *AegisPostgresReceiptSystemInterface) CancelReceipt(rid string) error { +func (rsif *GitusPostgresReceiptSystemInterface) CancelReceipt(rid string) error { pfx := rsif.config.ReceiptSystem.TablePrefix ctx := context.Background() tx, err := rsif.pool.Begin(ctx) @@ -130,7 +130,7 @@ func (rsif *AegisPostgresReceiptSystemInterface) CancelReceipt(rid string) error return nil } -func (rsif *AegisPostgresReceiptSystemInterface) GetAllReceipt(pageNum int, pageSize int) ([]*receipt.Receipt, error) { +func (rsif *GitusPostgresReceiptSystemInterface) GetAllReceipt(pageNum int, pageSize int) ([]*receipt.Receipt, error) { pfx := rsif.config.ReceiptSystem.TablePrefix ctx := context.Background() stmt, err := rsif.pool.Query(ctx, fmt.Sprintf(` @@ -156,7 +156,7 @@ LIMIT $1 OFFSET $2`, pfx), pageSize, pageNum*pageSize) return res, nil } -func (rsif *AegisPostgresReceiptSystemInterface) SearchReceipt(q string, pageNum int, pageSize int) ([]*receipt.Receipt, error) { +func (rsif *GitusPostgresReceiptSystemInterface) SearchReceipt(q string, pageNum int, pageSize int) ([]*receipt.Receipt, error) { pfx := rsif.config.Database.TablePrefix ctx := context.Background() pattern := strings.ReplaceAll(q, "\\", "\\\\") @@ -189,7 +189,7 @@ ORDER BY issue_time ASC LIMIT $3 OFFSET $4`, pfx), return res, nil } -func (rsif *AegisPostgresReceiptSystemInterface) EditReceipt(id string, robj *receipt.Receipt) error { +func (rsif *GitusPostgresReceiptSystemInterface) EditReceipt(id string, robj *receipt.Receipt) error { pfx := rsif.config.Database.TablePrefix ctx := context.Background() tx, err := rsif.pool.Begin(ctx) diff --git a/pkg/aegis/receipt/rsif.go b/pkg/gitus/receipt/rsif.go similarity index 98% rename from pkg/aegis/receipt/rsif.go rename to pkg/gitus/receipt/rsif.go index 12f9cfc..29434ac 100644 --- a/pkg/aegis/receipt/rsif.go +++ b/pkg/gitus/receipt/rsif.go @@ -15,7 +15,7 @@ type Receipt struct { TimeoutMinute int64 `json:"timeoutMinute"` } -type AegisReceiptSystemInterface interface { +type GitusReceiptSystemInterface interface { IsReceiptSystemUsable() (bool, error) Install() error Dispose() error diff --git a/pkg/aegis/receipt/sqlite/main.go b/pkg/gitus/receipt/sqlite/main.go similarity index 86% rename from pkg/aegis/receipt/sqlite/main.go rename to pkg/gitus/receipt/sqlite/main.go index f4b65bf..4cb6293 100644 --- a/pkg/aegis/receipt/sqlite/main.go +++ b/pkg/gitus/receipt/sqlite/main.go @@ -7,13 +7,13 @@ import ( "strings" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/receipt" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" _ "github.com/mattn/go-sqlite3" ) -type AegisSqliteReceiptSystemInterface struct { - config *aegis.AegisConfig +type GitusSqliteReceiptSystemInterface struct { + config *gitus.GitusConfig connection *sql.DB } @@ -21,7 +21,7 @@ var requiredTableList = []string{ "receipt", } -func NewSqliteReceiptSystemInterface(cfg *aegis.AegisConfig) (*AegisSqliteReceiptSystemInterface, error) { +func NewSqliteReceiptSystemInterface(cfg *gitus.GitusConfig) (*GitusSqliteReceiptSystemInterface, error) { p := cfg.ProperReceiptSystemPath() r, _ := url.Parse(p) q := r.Query() @@ -31,17 +31,17 @@ func NewSqliteReceiptSystemInterface(cfg *aegis.AegisConfig) (*AegisSqliteReceip r.RawQuery = q.Encode() db, err := sql.Open("sqlite3", r.String()) if err != nil { return nil, err } - return &AegisSqliteReceiptSystemInterface{ + return &GitusSqliteReceiptSystemInterface{ config: cfg, connection: db, }, nil } -func (rsif *AegisSqliteReceiptSystemInterface) Dispose() error { +func (rsif *GitusSqliteReceiptSystemInterface) Dispose() error { return rsif.connection.Close() } -func (rsif *AegisSqliteReceiptSystemInterface) IsReceiptSystemUsable() (bool, error) { +func (rsif *GitusSqliteReceiptSystemInterface) IsReceiptSystemUsable() (bool, error) { pfx := rsif.config.ReceiptSystem.TablePrefix stmt, err := rsif.connection.Prepare("SELECT 1 FROM sqlite_schema WHERE type = 'table' AND name = ?") if err != nil { return false, err } @@ -57,7 +57,7 @@ func (rsif *AegisSqliteReceiptSystemInterface) IsReceiptSystemUsable() (bool, er return true, nil } -func (rsif *AegisSqliteReceiptSystemInterface) Install() error { +func (rsif *GitusSqliteReceiptSystemInterface) Install() error { pfx := rsif.config.ReceiptSystem.TablePrefix tx, err := rsif.connection.Begin() if err != nil { return err } @@ -77,7 +77,7 @@ CREATE TABLE IF NOT EXISTS %s_receipt ( return nil } -func (rsif *AegisSqliteReceiptSystemInterface) RetrieveReceipt(rid string) (*receipt.Receipt, error) { +func (rsif *GitusSqliteReceiptSystemInterface) RetrieveReceipt(rid string) (*receipt.Receipt, error) { pfx := rsif.config.ReceiptSystem.TablePrefix stmt, err := rsif.connection.Prepare(fmt.Sprintf(` SELECT command, issue_time, timeout_minute @@ -100,7 +100,7 @@ WHERE id = ? }, nil } -func (rsif *AegisSqliteReceiptSystemInterface) IssueReceipt(timeoutMinute int64, command []string) (string, error) { +func (rsif *GitusSqliteReceiptSystemInterface) IssueReceipt(timeoutMinute int64, command []string) (string, error) { pfx := rsif.config.ReceiptSystem.TablePrefix tx, err := rsif.connection.Begin() if err != nil { return "", err } @@ -118,7 +118,7 @@ VALUES (?,?,?,?) return rid, nil } -func (rsif *AegisSqliteReceiptSystemInterface) CancelReceipt(rid string) error { +func (rsif *GitusSqliteReceiptSystemInterface) CancelReceipt(rid string) error { pfx := rsif.config.ReceiptSystem.TablePrefix tx, err := rsif.connection.Begin() if err != nil { return err } @@ -132,7 +132,7 @@ func (rsif *AegisSqliteReceiptSystemInterface) CancelReceipt(rid string) error { return nil } -func (rsif *AegisSqliteReceiptSystemInterface) GetAllReceipt(pageNum int, pageSize int) ([]*receipt.Receipt, error) { +func (rsif *GitusSqliteReceiptSystemInterface) GetAllReceipt(pageNum int, pageSize int) ([]*receipt.Receipt, error) { pfx := rsif.config.ReceiptSystem.TablePrefix stmt, err := rsif.connection.Prepare(fmt.Sprintf(` SELECT id, command, issue_time, timeout_minute @@ -160,7 +160,7 @@ LIMIT ? OFFSET ?`, pfx)) return res, nil } -func (rsif *AegisSqliteReceiptSystemInterface) SearchReceipt(q string, pageNum int, pageSize int) ([]*receipt.Receipt, error) { +func (rsif *GitusSqliteReceiptSystemInterface) SearchReceipt(q string, pageNum int, pageSize int) ([]*receipt.Receipt, error) { pfx := rsif.config.ReceiptSystem.TablePrefix pattern := strings.ReplaceAll(q, "\\", "\\\\") pattern = strings.ReplaceAll(pattern, "%", "\\%") @@ -191,7 +191,7 @@ ORDER BY rowid ASC LIMIT ? OFFSET ?`, pfx)) return res, nil } -func (rsif *AegisSqliteReceiptSystemInterface) EditReceipt(id string, robj *receipt.Receipt) error { +func (rsif *GitusSqliteReceiptSystemInterface) EditReceipt(id string, robj *receipt.Receipt) error { pfx := rsif.config.ReceiptSystem.TablePrefix tx, err := rsif.connection.Begin() if err != nil { return err } diff --git a/pkg/aegis/session/dbif.go b/pkg/gitus/session/dbif.go similarity index 75% rename from pkg/aegis/session/dbif.go rename to pkg/gitus/session/dbif.go index e3cf460..3ad0f1c 100644 --- a/pkg/aegis/session/dbif.go +++ b/pkg/gitus/session/dbif.go @@ -4,19 +4,19 @@ import ( "math/rand" ) -type AegisSession struct { +type GitusSession struct { Username string Id string Timestamp int64 } -type AegisSessionStore interface { +type GitusSessionStore interface { Install() error Dispose() error IsSessionStoreUsable() (bool, error) RegisterSession(username string, session string) error - RetrieveSession(username string) ([]*AegisSession, error) - RetrieveSessionByKey(username string, session string) (*AegisSession, error) + RetrieveSession(username string) ([]*GitusSession, error) + RetrieveSessionByKey(username string, session string) (*GitusSession, error) VerifySession(username string, target string) (bool, error) RevokeSession(username string, target string) error } diff --git a/pkg/aegis/session/in_memory/main.go b/pkg/gitus/session/in_memory/main.go similarity index 76% rename from pkg/aegis/session/in_memory/main.go rename to pkg/gitus/session/in_memory/main.go index d9f957f..5cc0d57 100644 --- a/pkg/aegis/session/in_memory/main.go +++ b/pkg/gitus/session/in_memory/main.go @@ -6,33 +6,33 @@ import ( "strings" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/session" - "github.com/bctnry/aegis/pkg/tcache" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session" + "github.com/GitusCodeForge/Gitus/pkg/tcache" ) -type AegisInMemorySessionStore struct { - config *aegis.AegisConfig +type GitusInMemorySessionStore struct { + config *gitus.GitusConfig cache *tcache.TCache } -func NewAegisInMemorySessionStore(cfg *aegis.AegisConfig) (*AegisInMemorySessionStore, error) { +func NewGitusInMemorySessionStore(cfg *gitus.GitusConfig) (*GitusInMemorySessionStore, error) { c := tcache.NewTCache(24 * time.Hour) - return &AegisInMemorySessionStore{ + return &GitusInMemorySessionStore{ config: cfg, cache: c, }, nil } -func (ssif *AegisInMemorySessionStore) Install() error { +func (ssif *GitusInMemorySessionStore) Install() error { return nil } -func (ssif *AegisInMemorySessionStore) IsSessionStoreUsable() (bool, error) { +func (ssif *GitusInMemorySessionStore) IsSessionStoreUsable() (bool, error) { return true, nil } -func (ssif *AegisInMemorySessionStore) Dispose() error { +func (ssif *GitusInMemorySessionStore) Dispose() error { return nil } @@ -53,7 +53,7 @@ func removeFromSet(set string, s string) string { return set[0:i] + set[i+len(ss):] } -func (ssif *AegisInMemorySessionStore) RegisterSession(name string, session string) error { +func (ssif *GitusInMemorySessionStore) RegisterSession(name string, session string) error { key := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, name) i, _ := ssif.cache.Get(key) ssif.cache.Register(key, insertSet(i, session), 24*time.Hour) @@ -74,17 +74,17 @@ func (ssif *AegisInMemorySessionStore) RegisterSession(name string, session stri return nil } -func (ssif *AegisInMemorySessionStore) RetrieveSession(name string) ([]*session.AegisSession, error) { +func (ssif *GitusInMemorySessionStore) RetrieveSession(name string) ([]*session.GitusSession, error) { groupKey := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, name) i, _ := ssif.cache.Get(groupKey) - res := make([]*session.AegisSession, 0) + res := make([]*session.GitusSession, 0) newset := "" for k := range strings.SplitSeq(string(i[1:len(i)]), "}{") { kk := fmt.Sprintf("%s:%s", groupKey, k) v, _ := ssif.cache.Get(kk) if v != "" { timestamp, _ := strconv.ParseInt(v, 10, 64) - res = append(res, &session.AegisSession{ + res = append(res, &session.GitusSession{ Username: name, Id: k, Timestamp: timestamp, @@ -100,18 +100,18 @@ func (ssif *AegisInMemorySessionStore) RetrieveSession(name string) ([]*session. return res, nil } -func (ssif *AegisInMemorySessionStore) RetrieveSessionByKey(username string, sessionid string) (*session.AegisSession, error) { +func (ssif *GitusInMemorySessionStore) RetrieveSessionByKey(username string, sessionid string) (*session.GitusSession, error) { key := fmt.Sprintf("%s:%s:session:%s", ssif.config.Session.TablePrefix, username, sessionid) i, _ := ssif.cache.Get(key) timestamp, _ := strconv.ParseInt(i, 10, 64) - return &session.AegisSession{ + return &session.GitusSession{ Username: username, Id: sessionid, Timestamp: timestamp, }, nil } -func (ssif *AegisInMemorySessionStore) VerifySession(name string, target string) (bool, error) { +func (ssif *GitusInMemorySessionStore) VerifySession(name string, target string) (bool, error) { key := fmt.Sprintf("%s:%s:session:%s", ssif.config.Session.TablePrefix, name, target) i, _ := ssif.cache.Get(key) if i == "" { return false, nil } @@ -123,7 +123,7 @@ func (ssif *AegisInMemorySessionStore) VerifySession(name string, target string) return true, nil } -func (ssif *AegisInMemorySessionStore) RevokeSession(username string, target string) error { +func (ssif *GitusInMemorySessionStore) RevokeSession(username string, target string) error { // NOTE: we don't have transaction semantics here, which could be // a problem down the line. // TODO: attempt to fix this. diff --git a/pkg/gitus/session/init/main.go b/pkg/gitus/session/init/main.go new file mode 100644 index 0000000..ca61fd0 --- /dev/null +++ b/pkg/gitus/session/init/main.go @@ -0,0 +1,28 @@ +package init + +import ( + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session/in_memory" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session/memcached" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session/redis_like" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session/sqlite" +) + + +func InitializeDatabase(cfg *gitus.GitusConfig) (session.GitusSessionStore, error) { + switch cfg.Session.Type { + case "sqlite": return sqlite.NewGitusSqliteSessionStore(cfg) + case "valkey": fallthrough + case "keydb": fallthrough + case "redis": + return redis_like.NewGitusRedisLikeSessionStore(cfg) + case "memcached": + return memcached.NewGitusMemcachedSessionStore(cfg) + case "in_memory": + return in_memory.NewGitusInMemorySessionStore(cfg) + } + return nil, db.ErrDatabaseNotSupported +} + diff --git a/pkg/aegis/session/memcached/main.go b/pkg/gitus/session/memcached/main.go similarity index 80% rename from pkg/aegis/session/memcached/main.go rename to pkg/gitus/session/memcached/main.go index ea9aecf..42c4422 100644 --- a/pkg/aegis/session/memcached/main.go +++ b/pkg/gitus/session/memcached/main.go @@ -7,33 +7,33 @@ import ( "strings" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/session" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session" "github.com/bradfitz/gomemcache/memcache" ) -type AegisMemcachedSessionStore struct { - config *aegis.AegisConfig +type GitusMemcachedSessionStore struct { + config *gitus.GitusConfig connection *memcache.Client } -func NewAegisMemcachedSessionStore(cfg *aegis.AegisConfig) (*AegisMemcachedSessionStore, error) { +func NewGitusMemcachedSessionStore(cfg *gitus.GitusConfig) (*GitusMemcachedSessionStore, error) { c := memcache.New(cfg.Session.Host) - return &AegisMemcachedSessionStore{ + return &GitusMemcachedSessionStore{ config: cfg, connection: c, }, nil } -func (ssif *AegisMemcachedSessionStore) Install() error { +func (ssif *GitusMemcachedSessionStore) Install() error { return nil } -func (ssif *AegisMemcachedSessionStore) IsSessionStoreUsable() (bool, error) { +func (ssif *GitusMemcachedSessionStore) IsSessionStoreUsable() (bool, error) { return true, nil } -func (ssif *AegisMemcachedSessionStore) Dispose() error { +func (ssif *GitusMemcachedSessionStore) Dispose() error { return ssif.connection.Close() } @@ -63,7 +63,7 @@ func removeFromSet(set []byte, s string) []byte { return []byte(strings.Join(ress, ",")) } -func (ssif *AegisMemcachedSessionStore) RegisterSession(name string, session string) error { +func (ssif *GitusMemcachedSessionStore) RegisterSession(name string, session string) error { sessionSetKey := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, name) i, err := ssif.connection.Get(sessionSetKey) if err != nil { @@ -103,10 +103,10 @@ func (ssif *AegisMemcachedSessionStore) RegisterSession(name string, session str return nil } -func (ssif *AegisMemcachedSessionStore) RetrieveSession(name string) ([]*session.AegisSession, error) { +func (ssif *GitusMemcachedSessionStore) RetrieveSession(name string) ([]*session.GitusSession, error) { key := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, name) i, err := ssif.connection.Get(key) - res := make([]*session.AegisSession, 0) + res := make([]*session.GitusSession, 0) if err == memcache.ErrCacheMiss { return res, nil } if err != nil { return nil, err } for k := range strings.SplitSeq(string(i.Value), ",") { @@ -119,7 +119,7 @@ func (ssif *AegisMemcachedSessionStore) RetrieveSession(name string) ([]*session val = string(v.Value) } timestamp, _ := strconv.ParseInt(val, 10, 64) - res = append(res, &session.AegisSession{ + res = append(res, &session.GitusSession{ Username: name, Id: k, Timestamp: timestamp, @@ -128,19 +128,19 @@ func (ssif *AegisMemcachedSessionStore) RetrieveSession(name string) ([]*session return res, nil } -func (ssif *AegisMemcachedSessionStore) RetrieveSessionByKey(username string, sessionid string) (*session.AegisSession, error) { +func (ssif *GitusMemcachedSessionStore) RetrieveSessionByKey(username string, sessionid string) (*session.GitusSession, error) { key := fmt.Sprintf("%s:%s:session:%s", ssif.config.Session.TablePrefix, username, sessionid) i, err := ssif.connection.Get(key) if err != nil { return nil, err } timestamp, _ := strconv.ParseInt(string(i.Value), 10, 64) - return &session.AegisSession{ + return &session.GitusSession{ Username: username, Id: sessionid, Timestamp: timestamp, }, nil } -func (ssif *AegisMemcachedSessionStore) VerifySession(name string, target string) (bool, error) { +func (ssif *GitusMemcachedSessionStore) VerifySession(name string, target string) (bool, error) { key := fmt.Sprintf("%s:%s:session:%s", ssif.config.Session.TablePrefix, name, target) i, err := ssif.connection.Get(key) if err == memcache.ErrCacheMiss { return false, nil } @@ -149,7 +149,7 @@ func (ssif *AegisMemcachedSessionStore) VerifySession(name string, target string return true, nil } -func (ssif *AegisMemcachedSessionStore) RevokeSession(username string, target string) error { +func (ssif *GitusMemcachedSessionStore) RevokeSession(username string, target string) error { // NOTE: we don't have transaction semantics here, which could be // a problem down the line. // TODO: attempt to fix this. diff --git a/pkg/aegis/session/redis_like/main.go b/pkg/gitus/session/redis_like/main.go similarity index 74% rename from pkg/aegis/session/redis_like/main.go rename to pkg/gitus/session/redis_like/main.go index 23a749a..2cfe11a 100644 --- a/pkg/aegis/session/redis_like/main.go +++ b/pkg/gitus/session/redis_like/main.go @@ -6,42 +6,42 @@ import ( "strconv" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/session" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session" "github.com/redis/go-redis/v9" ) -type AegisRedisLikeSessionStore struct { - config *aegis.AegisConfig +type GitusRedisLikeSessionStore struct { + config *gitus.GitusConfig connection *redis.Client } -func NewAegisRedisLikeSessionStore(cfg *aegis.AegisConfig) (*AegisRedisLikeSessionStore, error) { +func NewGitusRedisLikeSessionStore(cfg *gitus.GitusConfig) (*GitusRedisLikeSessionStore, error) { c := redis.NewClient(&redis.Options{ Addr: cfg.Session.Host, Username: cfg.Session.UserName, Password: cfg.Session.Password, DB: cfg.Session.DatabaseNumber, }) - return &AegisRedisLikeSessionStore{ + return &GitusRedisLikeSessionStore{ config: cfg, connection: c, }, nil } -func (ssif *AegisRedisLikeSessionStore) Install() error { +func (ssif *GitusRedisLikeSessionStore) Install() error { return nil } -func (ssif *AegisRedisLikeSessionStore) IsSessionStoreUsable() (bool, error) { +func (ssif *GitusRedisLikeSessionStore) IsSessionStoreUsable() (bool, error) { return true, nil } -func (ssif *AegisRedisLikeSessionStore) Dispose() error { +func (ssif *GitusRedisLikeSessionStore) Dispose() error { return ssif.connection.Close() } -func (ssif *AegisRedisLikeSessionStore) RegisterSession(name string, session string) error { +func (ssif *GitusRedisLikeSessionStore) RegisterSession(name string, session string) error { key := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, name) ctx := context.TODO() // timeoutStr := fmt.Sprintf("%d", 24 * 60 * 60) @@ -51,7 +51,7 @@ func (ssif *AegisRedisLikeSessionStore) RegisterSession(name string, session str return nil } -func (ssif *AegisRedisLikeSessionStore) RetrieveSession(name string) ([]*session.AegisSession, error) { +func (ssif *GitusRedisLikeSessionStore) RetrieveSession(name string) ([]*session.GitusSession, error) { key := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, name) // TODO: session being a set is reserved for the support of multiple // sessions. we currently don't have related logic yet; this is here @@ -62,7 +62,7 @@ func (ssif *AegisRedisLikeSessionStore) RetrieveSession(name string) ([]*session // told by Redis's documentations) does not guarantee the number of // values and you "should not consider the iteration complete as long // as the returned cursor is not zero". - res := make([]*session.AegisSession, 0) + res := make([]*session.GitusSession, 0) lastCursor := uint64(0) for { cmd := ssif.connection.HScan(context.TODO(), key, uint64(lastCursor), "*", 0) @@ -72,7 +72,7 @@ func (ssif *AegisRedisLikeSessionStore) RetrieveSession(name string) ([]*session lenk := len(keys) for i < lenk { timestamp, _ := strconv.ParseInt(keys[2*i+1], 10, 64) - res = append(res, &session.AegisSession{ + res = append(res, &session.GitusSession{ Username: name, Id: keys[2*i], Timestamp: timestamp, @@ -85,7 +85,7 @@ func (ssif *AegisRedisLikeSessionStore) RetrieveSession(name string) ([]*session return res, nil } -func (ssif *AegisRedisLikeSessionStore) RetrieveSessionByKey(username string, sessionid string) (*session.AegisSession, error) { +func (ssif *GitusRedisLikeSessionStore) RetrieveSessionByKey(username string, sessionid string) (*session.GitusSession, error) { key := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, username) cmd := ssif.connection.HGet(context.TODO(), key, sessionid) if cmd.Err() == redis.Nil { return nil, nil } @@ -94,14 +94,14 @@ func (ssif *AegisRedisLikeSessionStore) RetrieveSessionByKey(username string, se if err != nil { return nil, err } if len(r) <= 0 { return nil, nil } timestamp, _ := strconv.ParseInt(r, 10, 64) - return &session.AegisSession{ + return &session.GitusSession{ Username: username, Id: sessionid, Timestamp: timestamp, }, nil } -func (ssif *AegisRedisLikeSessionStore) VerifySession(name string, target string) (bool, error) { +func (ssif *GitusRedisLikeSessionStore) VerifySession(name string, target string) (bool, error) { key := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, name) cmd := ssif.connection.HGet(context.TODO(), key, target) if cmd.Err() == redis.Nil { return false, nil } @@ -112,7 +112,7 @@ func (ssif *AegisRedisLikeSessionStore) VerifySession(name string, target string return true, nil } -func (ssif *AegisRedisLikeSessionStore) RevokeSession(username string, target string) error { +func (ssif *GitusRedisLikeSessionStore) RevokeSession(username string, target string) error { key := fmt.Sprintf("%s:%s:session", ssif.config.Session.TablePrefix, username) cmd := ssif.connection.HDel(context.TODO(), key, target) if cmd.Err() != nil { return cmd.Err() } diff --git a/pkg/aegis/session/sqlite/install.go b/pkg/gitus/session/sqlite/install.go similarity index 87% rename from pkg/aegis/session/sqlite/install.go rename to pkg/gitus/session/sqlite/install.go index e250697..33984a7 100644 --- a/pkg/aegis/session/sqlite/install.go +++ b/pkg/gitus/session/sqlite/install.go @@ -2,7 +2,7 @@ package sqlite import "fmt" -func (ss *AegisSqliteSessionStore) Install() error { +func (ss *GitusSqliteSessionStore) Install() error { tx, err := ss.connection.Begin() if err != nil { return err } defer tx.Rollback() diff --git a/pkg/aegis/session/sqlite/main.go b/pkg/gitus/session/sqlite/main.go similarity index 77% rename from pkg/aegis/session/sqlite/main.go rename to pkg/gitus/session/sqlite/main.go index 917cf0d..85ea44a 100644 --- a/pkg/aegis/session/sqlite/main.go +++ b/pkg/gitus/session/sqlite/main.go @@ -6,17 +6,17 @@ import ( "fmt" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/session" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session" _ "github.com/mattn/go-sqlite3" ) -type AegisSqliteSessionStore struct { - config *aegis.AegisConfig +type GitusSqliteSessionStore struct { + config *gitus.GitusConfig connection *sql.DB } -func NewAegisSqliteSessionStore(cfg *aegis.AegisConfig) (*AegisSqliteSessionStore, error) { +func NewGitusSqliteSessionStore(cfg *gitus.GitusConfig) (*GitusSqliteSessionStore, error) { p := cfg.ProperSessionPath() r, _ := url.Parse(p) q := r.Query() @@ -26,17 +26,17 @@ func NewAegisSqliteSessionStore(cfg *aegis.AegisConfig) (*AegisSqliteSessionStor r.RawQuery = q.Encode() db, err := sql.Open("sqlite3", r.String()) if err != nil { return nil, err } - return &AegisSqliteSessionStore{ + return &GitusSqliteSessionStore{ config: cfg, connection: db, }, nil } -func (ss *AegisSqliteSessionStore) Dispose() error { +func (ss *GitusSqliteSessionStore) Dispose() error { return ss.connection.Close() } -func (ss *AegisSqliteSessionStore) IsSessionStoreUsable() (bool, error) { +func (ss *GitusSqliteSessionStore) IsSessionStoreUsable() (bool, error) { tableName := fmt.Sprintf("%ssession", ss.config.Session.TablePrefix) stmt, err := ss.connection.Prepare("SELECT 1 FROM sqlite_schema WHERE type = 'table' AND name = ?") if err != nil { return false, err } @@ -50,7 +50,7 @@ func (ss *AegisSqliteSessionStore) IsSessionStoreUsable() (bool, error) { return true, nil } -func (ss *AegisSqliteSessionStore) RegisterSession(name string, session string) error { +func (ss *GitusSqliteSessionStore) RegisterSession(name string, session string) error { tx, err := ss.connection.Begin() if err != nil { return err } stmt, err := tx.Prepare(fmt.Sprintf("INSERT INTO %ssession(user_name, value, reg_timestamp) VALUES (?,?,?)", ss.config.Session.TablePrefix)) @@ -62,10 +62,10 @@ func (ss *AegisSqliteSessionStore) RegisterSession(name string, session string) return nil } -func (ss *AegisSqliteSessionStore) RetrieveSession(name string) ([]*session.AegisSession, error) { +func (ss *GitusSqliteSessionStore) RetrieveSession(name string) ([]*session.GitusSession, error) { stmt, err := ss.connection.Prepare(fmt.Sprintf("SELECT value, reg_timestamp FROM %ssession WHERE user_name = ?", ss.config.Session.TablePrefix)) if err != nil { return nil, err } - res := make([]*session.AegisSession, 0) + res := make([]*session.GitusSession, 0) if err != nil { return nil, err } r, err := stmt.Query(name) for r.Next() { @@ -73,7 +73,7 @@ func (ss *AegisSqliteSessionStore) RetrieveSession(name string) ([]*session.Aegi var timestamp int64 err = r.Scan(&id, ×tamp) if err != nil { return nil, err } - res = append(res, &session.AegisSession{ + res = append(res, &session.GitusSession{ Username: name, Id: id, Timestamp: timestamp, @@ -82,7 +82,7 @@ func (ss *AegisSqliteSessionStore) RetrieveSession(name string) ([]*session.Aegi return res, nil } -func (ss *AegisSqliteSessionStore) RetrieveSessionByKey(username string, key string) (*session.AegisSession, error) { +func (ss *GitusSqliteSessionStore) RetrieveSessionByKey(username string, key string) (*session.GitusSession, error) { stmt, err := ss.connection.Prepare(fmt.Sprintf("SELECT reg_timestamp FROM %ssession WHERE user_name = ? AND value = ?", ss.config.Session.TablePrefix)) if err != nil { return nil, err } r := stmt.QueryRow(username, key) @@ -90,14 +90,14 @@ func (ss *AegisSqliteSessionStore) RetrieveSessionByKey(username string, key str var timestamp int64 err = r.Scan(×tamp) if err != nil { return nil, err } - return &session.AegisSession{ + return &session.GitusSession{ Username: username, Id: key, Timestamp: timestamp, }, nil } -func (ss *AegisSqliteSessionStore) VerifySession(name string, target string) (bool, error) { +func (ss *GitusSqliteSessionStore) VerifySession(name string, target string) (bool, error) { stmt, err := ss.connection.Prepare(fmt.Sprintf("SELECT 1 FROM %ssession WHERE user_name = ? AND value = ?", ss.config.Session.TablePrefix)) if err != nil { return false, err } s := "" @@ -107,7 +107,7 @@ func (ss *AegisSqliteSessionStore) VerifySession(name string, target string) (bo return (len(s) > 0), nil } -func (ss *AegisSqliteSessionStore) RevokeSession(username string, target string) error { +func (ss *GitusSqliteSessionStore) RevokeSession(username string, target string) error { tx, err := ss.connection.Begin() if err != nil { return err } stmt, err := tx.Prepare(fmt.Sprintf("DELETE FROM %ssession WHERE user_name = ? AND value = ?", ss.config.Session.TablePrefix)) diff --git a/pkg/aegis/simple_mode/repo-config.go b/pkg/gitus/simple_mode/repo-config.go similarity index 82% rename from pkg/aegis/simple_mode/repo-config.go rename to pkg/gitus/simple_mode/repo-config.go index c9fb2ef..bad36aa 100644 --- a/pkg/aegis/simple_mode/repo-config.go +++ b/pkg/gitus/simple_mode/repo-config.go @@ -6,8 +6,8 @@ import ( "os" "path" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" ) // repo config manager. @@ -15,10 +15,10 @@ import ( type RepoConfigManager struct { rootPath string - config *aegis.AegisConfig + config *gitus.GitusConfig } -func ToManager(cfg *aegis.AegisConfig) *RepoConfigManager { +func ToManager(cfg *gitus.GitusConfig) *RepoConfigManager { return &RepoConfigManager{ rootPath: cfg.GitRoot, config: cfg, @@ -28,9 +28,9 @@ func ToManager(cfg *aegis.AegisConfig) *RepoConfigManager { func (rcm *RepoConfigManager) GetNamespace(nsName string) (*model.Namespace, error) { var configRelDirPath string if rcm.config.UseNamespace { - configRelDirPath = path.Join("_aegis", "__repo_config", "aegis_sync") + configRelDirPath = path.Join("_gitus", "__repo_config", "gitus_sync") } else { - configRelDirPath = path.Join("__repo_config", "aegis_sync") + configRelDirPath = path.Join("__repo_config", "gitus_sync") } nsConfigPath := path.Join(rcm.config.GitRoot, configRelDirPath, nsName, "config.json") nsConfig, err := model.ReadNamespaceConfigFromFile(nsConfigPath) @@ -53,9 +53,9 @@ func (rcm *RepoConfigManager) GetNamespace(nsName string) (*model.Namespace, err func (rcm *RepoConfigManager) GetRepository(nsName string, repoName string) (*model.Repository, error) { var configRelDirPath string if rcm.config.UseNamespace { - configRelDirPath = path.Join("_aegis", "__repo_config", "aegis_sync") + configRelDirPath = path.Join("_gitus", "__repo_config", "gitus_sync") } else { - configRelDirPath = path.Join("__repo_config", "aegis_sync") + configRelDirPath = path.Join("__repo_config", "gitus_sync") } repoConfigPath := path.Join(rcm.config.GitRoot, configRelDirPath, nsName, repoName, "config.json") repoConfig, err := model.ReadRepositoryConfigFromFile(repoConfigPath) diff --git a/pkg/aegis/ssh/main.go b/pkg/gitus/ssh/main.go similarity index 89% rename from pkg/aegis/ssh/main.go rename to pkg/gitus/ssh/main.go index 74a3751..0d597d1 100644 --- a/pkg/aegis/ssh/main.go +++ b/pkg/gitus/ssh/main.go @@ -9,8 +9,8 @@ import ( "regexp" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/shellparse" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/shellparse" ) type SSHKeyManagingContext struct { @@ -20,10 +20,10 @@ type SSHKeyManagingContext struct { notManaged []string } -var reParseKey = regexp.MustCompile("\\s*command=\"aegis -config .* ssh ([^ ]*) ([^ ]*)\"\\s*(.*)") +var reParseKey = regexp.MustCompile("\\s*command=\"gitus -config .* ssh ([^ ]*) ([^ ]*)\"\\s*(.*)") func parseKey(s string) (bool, string, string, string, error) { - // we expect all keys managed by aegis should have the prefix - // command="aegis -config {config-path} ssh {username} {keyname}" + // we expect all keys managed by gitus should have the prefix + // command="gitus -config {config-path} ssh {username} {keyname}" r := reParseKey k := r.FindSubmatch([]byte(s)) if len(k) <= 0 { return false, "", "", "", nil } @@ -31,7 +31,7 @@ func parseKey(s string) (bool, string, string, string, error) { } // create a new context but does not read the managed keys from the authorized_keys file. -func NewContext(cfg *aegis.AegisConfig) (*SSHKeyManagingContext, error) { +func NewContext(cfg *gitus.GitusConfig) (*SSHKeyManagingContext, error) { u, err := user.Lookup(cfg.GitUser) if err != nil { return nil, err } p := path.Join(u.HomeDir, ".ssh", "authorized_keys") @@ -55,7 +55,7 @@ func NewContext(cfg *aegis.AegisConfig) (*SSHKeyManagingContext, error) { } -func ToContext(cfg *aegis.AegisConfig) (*SSHKeyManagingContext, error) { +func ToContext(cfg *gitus.GitusConfig) (*SSHKeyManagingContext, error) { u, err := user.Lookup(cfg.GitUser) if err != nil { return nil, err } p := path.Join(u.HomeDir, ".ssh", "authorized_keys") @@ -107,7 +107,7 @@ func (ctx *SSHKeyManagingContext) Sync() error { quotedConfig := shellparse.Quote(ctx.configFilePath) for userName, pack := range ctx.Managed { for keyName, key := range pack { - _, err := fmt.Fprintf(f, "command=\"aegis -config \\\"%s\\\" ssh %s %s\" %s", quotedConfig, userName, keyName, key) + _, err := fmt.Fprintf(f, "command=\"gitus -config \\\"%s\\\" ssh %s %s\" %s", quotedConfig, userName, keyName, key) if err != nil { return err } _, err = f.WriteString("\n") if err != nil { return err } diff --git a/routes/aux.go b/routes/aux.go index 2e88fad..810856b 100644 --- a/routes/aux.go +++ b/routes/aux.go @@ -6,8 +6,8 @@ import ( "net/http" "strconv" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/templates" ) func LogIfError(err error) { diff --git a/routes/context.go b/routes/context.go index 08ad075..1784c09 100644 --- a/routes/context.go +++ b/routes/context.go @@ -12,32 +12,32 @@ import ( "path" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/confirm_code" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/mail" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/aegis/receipt" - "github.com/bctnry/aegis/pkg/aegis/session" - "github.com/bctnry/aegis/pkg/aegis/ssh" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/confirm_code" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/mail" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session" + "github.com/GitusCodeForge/Gitus/pkg/gitus/ssh" + "github.com/GitusCodeForge/Gitus/templates" ) type RouterContext struct { GitUserHomeDirectory string - Config *aegis.AegisConfig + Config *gitus.GitusConfig MasterTemplate *template.Template GitRepositoryList map[string]*model.Repository GitNamespaceList map[string]*model.Namespace - DatabaseInterface db.AegisDatabaseInterface - SessionInterface session.AegisSessionStore + DatabaseInterface db.GitusDatabaseInterface + SessionInterface session.GitusSessionStore SSHKeyManagingContext *ssh.SSHKeyManagingContext - ReceiptSystem receipt.AegisReceiptSystemInterface - Mailer mail.AegisMailerInterface + ReceiptSystem receipt.GitusReceiptSystemInterface + Mailer mail.GitusMailerInterface LoginInfo *templates.LoginInfoModel LastError error RateLimiter *RateLimiter - ConfirmCodeManager confirm_code.AegisConfirmCodeManager + ConfirmCodeManager confirm_code.GitusConfirmCodeManager SimpleModeConfigCache model.SimpleModeConfigCache } @@ -219,7 +219,7 @@ func (ctx *RouterContext) ResolveRepositoryFullName(str string) (string, string, var ok bool var err error var ns *model.Namespace - if ctx.Config.IsInPlainMode() || ctx.Config.OperationMode == aegis.OP_MODE_SIMPLE { + if ctx.Config.IsInPlainMode() || ctx.Config.OperationMode == gitus.OP_MODE_SIMPLE { ns, ok = ctx.GitNamespaceList[namespaceName] if !ok { err := ctx.SyncAllNamespacePlain() diff --git a/routes/controller/admin/db-setting.go b/routes/controller/admin/db-setting.go index 2ca1d9c..fea1767 100644 --- a/routes/controller/admin/db-setting.go +++ b/routes/controller/admin/db-setting.go @@ -4,8 +4,8 @@ import ( "fmt" "net/http" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindAdminDatabaseSettingController(ctx *RouterContext) { diff --git a/routes/controller/admin/edit-namespace.go b/routes/controller/admin/edit-namespace.go index dbe6b8f..927ac72 100644 --- a/routes/controller/admin/edit-namespace.go +++ b/routes/controller/admin/edit-namespace.go @@ -5,9 +5,9 @@ import ( "net/http" "strconv" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) @@ -63,7 +63,7 @@ func bindAdminEditNamespaceController(ctx *RouterContext) { ns.Title = title ns.Email = email ns.Owner = owner - ns.Status = model.AegisNamespaceStatus(i) + ns.Status = model.GitusNamespaceStatus(i) ns.Description = description err = rc.DatabaseInterface.UpdateNamespaceInfo(nsn, ns) if err != nil { diff --git a/routes/controller/admin/edit_user/gpg.go b/routes/controller/admin/edit_user/gpg.go index 661622f..b4999cf 100644 --- a/routes/controller/admin/edit_user/gpg.go +++ b/routes/controller/admin/edit_user/gpg.go @@ -5,10 +5,10 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/auxfuncs" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/auxfuncs" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) diff --git a/routes/controller/admin/edit_user/info.go b/routes/controller/admin/edit_user/info.go index 4e669cd..12a5e46 100644 --- a/routes/controller/admin/edit_user/info.go +++ b/routes/controller/admin/edit_user/info.go @@ -5,9 +5,9 @@ import ( "net/http" "strconv" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) @@ -67,11 +67,11 @@ func bindAdminEditUserInfoController(ctx *RouterContext) { rc.ReportNormalError("Invalid request", w, r) return } - if !rc.LoginInfo.IsSuperAdmin && model.AegisUserStatus(i) != model.SUPER_ADMIN { + if !rc.LoginInfo.IsSuperAdmin && model.GitusUserStatus(i) != model.SUPER_ADMIN { rc.ReportRedirect("/admin/user-list", 0, "Error", "Not enough permission.", w, r) return } - user.Status = model.AegisUserStatus(i) + user.Status = model.GitusUserStatus(i) err = rc.DatabaseInterface.UpdateUserInfo(un, user) if err != nil { rc.ReportInternalError(fmt.Sprintf("Failed to update user info: %s", err.Error()), w, r) diff --git a/routes/controller/admin/edit_user/init.go b/routes/controller/admin/edit_user/init.go index d5646ac..39e8719 100644 --- a/routes/controller/admin/edit_user/init.go +++ b/routes/controller/admin/edit_user/init.go @@ -1,7 +1,7 @@ package edit_user import ( - . "github.com/bctnry/aegis/routes" + . "github.com/GitusCodeForge/Gitus/routes" ) func BindAdminEditUserController(ctx *RouterContext) { diff --git a/routes/controller/admin/edit_user/ssh.go b/routes/controller/admin/edit_user/ssh.go index 7fc43f7..7e88c97 100644 --- a/routes/controller/admin/edit_user/ssh.go +++ b/routes/controller/admin/edit_user/ssh.go @@ -5,10 +5,10 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/auxfuncs" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/auxfuncs" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindAdminEditUserSSHController(ctx *RouterContext) { diff --git a/routes/controller/admin/index.go b/routes/controller/admin/index.go index 2c203c8..cc5b8d9 100644 --- a/routes/controller/admin/index.go +++ b/routes/controller/admin/index.go @@ -3,8 +3,8 @@ package admin import ( "net/http" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindAdminIndexController(ctx *RouterContext) { diff --git a/routes/controller/admin/init.go b/routes/controller/admin/init.go index bfe3da4..6adcf3b 100644 --- a/routes/controller/admin/init.go +++ b/routes/controller/admin/init.go @@ -1,9 +1,9 @@ package admin import ( - "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/routes/controller/admin/edit_user" - "github.com/bctnry/aegis/routes/controller/admin/rrdoc" + "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/routes/controller/admin/edit_user" + "github.com/GitusCodeForge/Gitus/routes/controller/admin/rrdoc" ) func BindAllAdminControllers(context *routes.RouterContext) { diff --git a/routes/controller/admin/mailer-setting.go b/routes/controller/admin/mailer-setting.go index fcdf2cf..828ea63 100644 --- a/routes/controller/admin/mailer-setting.go +++ b/routes/controller/admin/mailer-setting.go @@ -5,10 +5,10 @@ import ( "net/http" "strconv" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/mail" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/mail" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindAdminMailerSettingController(ctx *RouterContext) { @@ -43,7 +43,7 @@ func bindAdminMailerSettingController(ctx *RouterContext) { rc.ReportNormalError("Invalid request", w, r) return } - mailer, err := mail.CreateMailerFromMailerConfig(&aegis.AegisMailerConfig{ + mailer, err := mail.CreateMailerFromMailerConfig(&gitus.GitusMailerConfig{ Type: r.Form.Get("type"), SMTPServer: r.Form.Get("server"), SMTPPort: int(port), diff --git a/routes/controller/admin/namespace-list.go b/routes/controller/admin/namespace-list.go index b665267..6949cb2 100644 --- a/routes/controller/admin/namespace-list.go +++ b/routes/controller/admin/namespace-list.go @@ -6,9 +6,9 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) // /admin/namespace-list?p={pagenum}&s={pagesize}&q={query} @@ -85,7 +85,7 @@ func bindAdminNamespaceListController(ctx *RouterContext) { rc.ReportInternalError(fmt.Sprintf("Failed to register namespace: %s", err), w, r) return } - ns.Status = model.AegisNamespaceStatus(i) + ns.Status = model.GitusNamespaceStatus(i) ns.Title = title ns.Email = email ns.Owner = owner diff --git a/routes/controller/admin/new-user.go b/routes/controller/admin/new-user.go index 38bf717..480848d 100644 --- a/routes/controller/admin/new-user.go +++ b/routes/controller/admin/new-user.go @@ -5,9 +5,9 @@ import ( "net/http" "strconv" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) @@ -57,7 +57,7 @@ func bindAdminNewUserController(ctx *RouterContext) { })) return } - _, err = rc.DatabaseInterface.RegisterUser(userName, email, string(passwordHash), model.AegisUserStatus(i)) + _, err = rc.DatabaseInterface.RegisterUser(userName, email, string(passwordHash), model.GitusUserStatus(i)) if err != nil { LogTemplateError(rc.LoadTemplate("admin/new-user").Execute(w, templates.AdminConfigTemplateModel{ Config: rc.Config, diff --git a/routes/controller/admin/receipt-list.go b/routes/controller/admin/receipt-list.go index 8212bd7..e601e53 100644 --- a/routes/controller/admin/receipt-list.go +++ b/routes/controller/admin/receipt-list.go @@ -6,9 +6,9 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/receipt" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) // /admin/receipt/{{.Id}}/edit diff --git a/routes/controller/admin/reg-request.go b/routes/controller/admin/reg-request.go index 10f86ad..924ff40 100644 --- a/routes/controller/admin/reg-request.go +++ b/routes/controller/admin/reg-request.go @@ -6,10 +6,10 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/aegis/receipt" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) // /admin/reg-request?p={pagenum}&s={pagesize} diff --git a/routes/controller/admin/repo-list.go b/routes/controller/admin/repo-list.go index e004f3b..0a69122 100644 --- a/routes/controller/admin/repo-list.go +++ b/routes/controller/admin/repo-list.go @@ -6,9 +6,9 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) // /admin/repo-list?p={pagenum}&s={pagesize}&q={query} diff --git a/routes/controller/admin/rrdoc/delete.go b/routes/controller/admin/rrdoc/delete.go new file mode 100644 index 0000000..8840413 --- /dev/null +++ b/routes/controller/admin/rrdoc/delete.go @@ -0,0 +1,45 @@ +package rrdoc + +import ( + "fmt" + "net/http" + "os" + "path" + "slices" + "strconv" + + . "github.com/GitusCodeForge/Gitus/routes" +) + + +func bindAdminRRDocDeleteController(ctx *RouterContext) { + http.HandleFunc("GET /admin/rrdoc/{n}/delete", UseMiddleware( + []Middleware{ + Logged, LoginRequired, AdminRequired, + GlobalVisibility, ErrorGuard, + }, ctx, + func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { + n, err := strconv.ParseInt(r.PathValue("n"), 10, 32) + if err != nil { + rc.ReportNotFound("Required", "document", "instance", w, r) + return + } + if len(rc.Config.ReadingRequiredDocument) < int(n) { + rc.ReportNotFound("Required", "document", "instance", w, r) + return + } + p := rc.Config.ReadingRequiredDocument[int(n)-1] + tp := path.Join(rc.Config.StaticAssetDirectory, "_rrdoc", p.Path) + err = os.Remove(tp) + if err != nil { + rc.ReportInternalError(fmt.Sprintf("Failed to delete file %s: %s", p, err), w, r) + return + } + rc.Config.ReadingRequiredDocument = slices.Delete(rc.Config.ReadingRequiredDocument, int(n)-1, int(n)) + // we should probably turn this into a transaction... + rc.Config.Sync() + rc.ReportRedirect("/admin/rrdoc", 3, "Deleted", "The document you've specified has been deleted.", w, r) + }, + )) +} + diff --git a/routes/controller/admin/rrdoc/edit.go b/routes/controller/admin/rrdoc/edit.go new file mode 100644 index 0000000..bef1fc5 --- /dev/null +++ b/routes/controller/admin/rrdoc/edit.go @@ -0,0 +1,101 @@ +package rrdoc + +import ( + "errors" + "fmt" + "net/http" + "os" + "path" + "strconv" + "strings" + + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" +) + +func bindAdminRRDocEditController(ctx *RouterContext) { + http.HandleFunc("GET /admin/rrdoc/{n}/edit", UseMiddleware( + []Middleware{ + Logged, LoginRequired, AdminRequired, + GlobalVisibility, ErrorGuard, + }, ctx, + func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { + n, err := strconv.ParseInt(r.PathValue("n"), 10, 32) + if err != nil { + rc.ReportNotFound("Required", "document", "instance", w, r) + return + } + if len(rc.Config.ReadingRequiredDocument) < int(n) { + rc.ReportNotFound("Required", "document", "instance", w, r) + return + } + p := rc.Config.ReadingRequiredDocument[int(n)-1] + content := "" + if !(strings.HasPrefix(p.Path, "http://") || strings.HasPrefix(p.Path, "https://")) { + os.MkdirAll(path.Join(rc.Config.StaticAssetDirectory, "_rrdoc"), os.ModeDir) + fp := path.Join(rc.Config.StaticAssetDirectory, "_rrdoc", p.Path) + f, err := os.ReadFile(fp) + if err != nil { + if !errors.Is(err, os.ErrNotExist) { + rc.ReportInternalError(fmt.Sprintf("Cannot read file %s: %s", p.Path, err.Error()), w, r) + } + } else { + content = string(f) + } + } + w.Header().Add("Content-Type", "text/html") + w.WriteHeader(200) + LogTemplateError(rc.LoadTemplate("admin/rrdoc/edit").Execute(w, &templates.AdminRRDocEditTemplateModel{ + Config: rc.Config, + LoginInfo: rc.LoginInfo, + DocumentNumber: int(n), + Title: p.Title, + Path: p.Path, + Content: content, + })) + }, + )) + + http.HandleFunc("POST /admin/rrdoc/{n}/edit", UseMiddleware( + []Middleware{ + Logged, LoginRequired, AdminRequired, ValidPOSTRequestRequired, + GlobalVisibility, ErrorGuard, + }, ctx, + func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { + n, err := strconv.ParseInt(r.PathValue("n"), 10, 32) + if err != nil { + rc.ReportNotFound("Required", "document", "instance", w, r) + return + } + if len(rc.Config.ReadingRequiredDocument) < int(n) { + rc.ReportNotFound("Required", "document", "instance", w, r) + return + } + title := r.Form.Get("title") + p := strings.TrimSpace(r.Form.Get("path")) + content := r.Form.Get("content") + rc.Config.ReadingRequiredDocument[n-1].Title = title + rc.Config.ReadingRequiredDocument[n-1].Path = p + // don't sync until we have properly edited the file. + if !(strings.HasPrefix(p, "http://") || strings.HasPrefix(p, "https://")) { + os.MkdirAll(path.Join(rc.Config.StaticAssetDirectory, "_rrdoc"), os.ModeDir|0755) + fp := path.Join(rc.Config.StaticAssetDirectory, "_rrdoc", p) + f, err := os.OpenFile(fp, os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0644) + if err != nil { + rc.ReportInternalError(fmt.Sprintf("Failed to open file %s: %s", p, err), w, r) + return + } + _, err = f.Write([]byte(content)) + if err != nil { + rc.ReportInternalError(fmt.Sprintf("Failed to write to file: %s", err), w, r) + return + } + f.Close() + } + // we should probably turn this into a transaction... + rc.Config.Sync() + rc.ReportRedirect(fmt.Sprintf("/admin/rrdoc/%d/edit", n), 3, "Updated", "The document you've specified has been updated.", w, r) + }, + )) +} + diff --git a/routes/controller/admin/rrdoc/init.go b/routes/controller/admin/rrdoc/init.go new file mode 100644 index 0000000..d91ef05 --- /dev/null +++ b/routes/controller/admin/rrdoc/init.go @@ -0,0 +1,13 @@ +package rrdoc + +import ( + . "github.com/GitusCodeForge/Gitus/routes" +) + +func BindAdminRRDocController(ctx *RouterContext) { + bindAdminRRDocListController(ctx) + bindAdminRRDocNewController(ctx) + bindAdminRRDocEditController(ctx) + bindAdminRRDocDeleteController(ctx) +} + diff --git a/routes/controller/admin/rrdoc/list.go b/routes/controller/admin/rrdoc/list.go new file mode 100644 index 0000000..53ec465 --- /dev/null +++ b/routes/controller/admin/rrdoc/list.go @@ -0,0 +1,26 @@ +package rrdoc + +import ( + "net/http" + + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" +) + +func bindAdminRRDocListController(ctx *RouterContext) { + http.HandleFunc("GET /admin/rrdoc", UseMiddleware( + []Middleware{ + Logged, LoginRequired, AdminRequired, + GlobalVisibility, ErrorGuard, + }, ctx, + func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", "text/html") + w.WriteHeader(200) + LogTemplateError(rc.LoadTemplate("admin/rrdoc/list").Execute(w, &templates.AdminRRDocListTemplateModel{ + Config: rc.Config, + LoginInfo: rc.LoginInfo, + })) + }, + )) +} + diff --git a/routes/controller/admin/rrdoc/new.go b/routes/controller/admin/rrdoc/new.go new file mode 100644 index 0000000..69e29c7 --- /dev/null +++ b/routes/controller/admin/rrdoc/new.go @@ -0,0 +1,69 @@ +package rrdoc + +import ( + "fmt" + "net/http" + "os" + "path" + "strings" + + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" +) + +func bindAdminRRDocNewController(ctx *RouterContext) { + http.HandleFunc("GET /admin/rrdoc/new", UseMiddleware( + []Middleware{ + Logged, LoginRequired, AdminRequired, + GlobalVisibility, ErrorGuard, + }, ctx, + func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", "text/html") + w.WriteHeader(200) + LogTemplateError(rc.LoadTemplate("admin/rrdoc/edit").Execute(w, &templates.AdminRRDocEditTemplateModel{ + Config: rc.Config, + LoginInfo: rc.LoginInfo, + DocumentNumber: -1, + Title: "", + Path: "", + Content: "", + })) + }, + )) + + http.HandleFunc("POST /admin/rrdoc/new", UseMiddleware( + []Middleware{ + Logged, LoginRequired, AdminRequired, ValidPOSTRequestRequired, + GlobalVisibility, ErrorGuard, + }, ctx, + func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { + title := r.Form.Get("title") + p := strings.TrimSpace(r.Form.Get("path")) + content := r.Form.Get("content") + rc.Config.ReadingRequiredDocument = append(rc.Config.ReadingRequiredDocument, struct{Title string; Path string}{ + Title: title, + Path: p, + }) + // don't sync until we have properly edited the file. + if !(strings.HasPrefix(p, "http://") || strings.HasPrefix(p, "https://")) { + os.MkdirAll(path.Join(rc.Config.StaticAssetDirectory, "_rrdoc"), os.ModeDir|0755) + fp := path.Join(rc.Config.StaticAssetDirectory, "_rrdoc", p) + f, err := os.OpenFile(fp, os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0644) + if err != nil { + rc.ReportInternalError(fmt.Sprintf("Failed to open file %s: %s", p, err), w, r) + return + } + _, err = f.Write([]byte(content)) + if err != nil { + rc.ReportInternalError(fmt.Sprintf("Failed to write to file: %s", err), w, r) + return + } + f.Close() + } + // we should probably turn this into a transaction... + rc.Config.Sync() + rc.ReportRedirect("/admin/rrdoc/new", 3, "Updated", "The document you've specified has been updated.", w, r) + }, + )) +} + diff --git a/routes/controller/admin/rs-setting.go b/routes/controller/admin/rs-setting.go index 6445b57..dff2dec 100644 --- a/routes/controller/admin/rs-setting.go +++ b/routes/controller/admin/rs-setting.go @@ -4,8 +4,8 @@ import ( "fmt" "net/http" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindAdminReceiptSystemSettingController(ctx *RouterContext) { diff --git a/routes/controller/admin/session-setting.go b/routes/controller/admin/session-setting.go index 18907c9..7bd5fa3 100644 --- a/routes/controller/admin/session-setting.go +++ b/routes/controller/admin/session-setting.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindAdminSessionSettingController(ctx *RouterContext) { diff --git a/routes/controller/admin/site-config.go b/routes/controller/admin/site-config.go index 599388b..d8e346e 100644 --- a/routes/controller/admin/site-config.go +++ b/routes/controller/admin/site-config.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindAdminSiteConfigController(ctx *RouterContext) { diff --git a/routes/controller/admin/site-lockdown.go b/routes/controller/admin/site-lockdown.go index cfa4c5f..7b620ca 100644 --- a/routes/controller/admin/site-lockdown.go +++ b/routes/controller/admin/site-lockdown.go @@ -5,9 +5,9 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindAdminSiteLockdownController(ctx *RouterContext) { @@ -40,12 +40,12 @@ func bindAdminSiteLockdownController(ctx *RouterContext) { t := strings.TrimSpace(r.Form.Get("type")) switch t { case "public": - rc.Config.GlobalVisibility = aegis.GLOBAL_VISIBILITY_PUBLIC + rc.Config.GlobalVisibility = gitus.GLOBAL_VISIBILITY_PUBLIC case "private": - rc.Config.GlobalVisibility = aegis.GLOBAL_VISIBILITY_PRIVATE + rc.Config.GlobalVisibility = gitus.GLOBAL_VISIBILITY_PRIVATE rc.Config.PrivateNoticeMessage = r.Form.Get("private-notice-message") case "shutdown": - rc.Config.GlobalVisibility = aegis.GLOBAL_VISIBILITY_SHUTDOWN + rc.Config.GlobalVisibility = gitus.GLOBAL_VISIBILITY_SHUTDOWN ul := make([]string, 0) for k := range strings.SplitSeq(r.Form.Get("full-access-user"), ",") { ul = append(ul, strings.TrimSpace(k)) @@ -53,7 +53,7 @@ func bindAdminSiteLockdownController(ctx *RouterContext) { rc.Config.FullAccessUser = ul rc.Config.ShutdownMessage = r.Form.Get("shutdown-notice-message") case "maintenance": - rc.Config.GlobalVisibility = aegis.GLOBAL_VISIBILITY_MAINTENANCE + rc.Config.GlobalVisibility = gitus.GLOBAL_VISIBILITY_MAINTENANCE rc.Config.MaintenanceMessage = r.Form.Get("maintenance-notice-message") } err := rc.Config.Sync() diff --git a/routes/controller/admin/user-list.go b/routes/controller/admin/user-list.go index dfdd989..335e538 100644 --- a/routes/controller/admin/user-list.go +++ b/routes/controller/admin/user-list.go @@ -6,9 +6,9 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) // /admin/user-list?p={pagenum}&s={pagesize} @@ -30,7 +30,7 @@ func bindAdminUserListController(ctx *RouterContext) { if i % pageSize != 0 { totalPage += 1 } if pageNum > totalPage { pageNum = totalPage } if pageNum <= 1 { pageNum = 1 } - var userList []*model.AegisUser + var userList []*model.GitusUser if len(q) > 0 { userList, err = rc.DatabaseInterface.SearchForUser(q, pageNum-1, pageSize) } else { diff --git a/routes/controller/all.go b/routes/controller/all.go index 7d6eb03..7f42cfc 100644 --- a/routes/controller/all.go +++ b/routes/controller/all.go @@ -5,10 +5,10 @@ import ( "slices" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) // list of namespace if enabled, @@ -26,7 +26,7 @@ func bindAllController(ctx *routes.RouterContext) { var nsl map[string]*model.Namespace var nslCount int64 var pageInfo *templates.PageInfoModel - if ctx.Config.OperationMode != aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode != gitus.OP_MODE_NORMAL { if len(q) > 0 { nsl, err = ctx.Config.SearchAllNamespacePlain(q) } else { @@ -91,7 +91,7 @@ func bindAllController(ctx *routes.RouterContext) { var repol []*model.Repository var repolCount int64 var pageInfo *templates.PageInfoModel - if ctx.Config.OperationMode != aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode != gitus.OP_MODE_NORMAL { if len(q) > 0 { repol, err = ctx.Config.SearchAllRepositoryPlain(q) } else { diff --git a/routes/controller/aux.go b/routes/controller/aux.go index 5718fe0..6682f18 100644 --- a/routes/controller/aux.go +++ b/routes/controller/aux.go @@ -15,8 +15,8 @@ import ( chromaHtml "github.com/alecthomas/chroma/v2/formatters/html" "github.com/alecthomas/chroma/v2/lexers" "github.com/alecthomas/chroma/v2/styles" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" "golang.org/x/crypto/bcrypt" ) diff --git a/routes/controller/blob.go b/routes/controller/blob.go index 1c1cdd1..1babeb0 100644 --- a/routes/controller/blob.go +++ b/routes/controller/blob.go @@ -5,11 +5,11 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) diff --git a/routes/controller/branch.go b/routes/controller/branch.go index d5a3459..4b54f3c 100644 --- a/routes/controller/branch.go +++ b/routes/controller/branch.go @@ -9,12 +9,12 @@ import ( "path" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func handleBranchSnapshotRequest(repo *model.Repository, branchName string, obj gitlib.GitObject, w http.ResponseWriter) { @@ -99,7 +99,7 @@ func bindBranchController(ctx *RouterContext) { cobj := gobj.(*gitlib.CommitObject) m := make(map[string]string, 0) - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { m[cobj.AuthorInfo.AuthorEmail] = "" m[cobj.CommitterInfo.AuthorEmail] = "" rc.DatabaseInterface.ResolveMultipleEmailToUsername(m) diff --git a/routes/controller/commit.go b/routes/controller/commit.go index 06985f4..bacaf22 100644 --- a/routes/controller/commit.go +++ b/routes/controller/commit.go @@ -7,12 +7,12 @@ import ( "path" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func handleCommitSnapshotRequest(repo *model.Repository, commitId string, obj gitlib.GitObject, w http.ResponseWriter) { @@ -83,7 +83,7 @@ func bindCommitController(ctx *RouterContext) { cobj := gobj.(*gitlib.CommitObject) m := make(map[string]string, 0) - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { m[cobj.AuthorInfo.AuthorEmail] = "" m[cobj.CommitterInfo.AuthorEmail] = "" rc.DatabaseInterface.ResolveMultipleEmailToUsername(m) diff --git a/routes/controller/confirm-registration.go b/routes/controller/confirm-registration.go index 6b892cf..27de0e1 100644 --- a/routes/controller/confirm-registration.go +++ b/routes/controller/confirm-registration.go @@ -5,21 +5,21 @@ import ( "net/http" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/aegis/receipt" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindConfirmRegistrationController(ctx *RouterContext) { http.HandleFunc("GET /confirm-registration", UseMiddleware( []Middleware{Logged, UseLoginInfo, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility == aegis.GLOBAL_VISIBILITY_SHUTDOWN { + if ctx.Config.GlobalVisibility == gitus.GLOBAL_VISIBILITY_SHUTDOWN { FoundAt(w, "/shutdown-notice") } - if ctx.Config.GlobalVisibility == aegis.GLOBAL_VISIBILITY_MAINTENANCE { + if ctx.Config.GlobalVisibility == gitus.GLOBAL_VISIBILITY_MAINTENANCE { FoundAt(w, "/maintenance-notice") } rid := r.URL.Query().Get("id") diff --git a/routes/controller/diff.go b/routes/controller/diff.go index 231de1b..f9b3d13 100644 --- a/routes/controller/diff.go +++ b/routes/controller/diff.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindDiffController(ctx *RouterContext) { @@ -65,7 +65,7 @@ func bindDiffController(ctx *RouterContext) { } co := cobj.(*gitlib.CommitObject) m := make(map[string]string, 0) - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { m[co.AuthorInfo.AuthorEmail] = "" m[co.CommitterInfo.AuthorEmail] = "" ctx.DatabaseInterface.ResolveMultipleEmailToUsername(m) diff --git a/routes/controller/dynamic-asset.go b/routes/controller/dynamic-asset.go index 0b922cd..b3dfca6 100644 --- a/routes/controller/dynamic-asset.go +++ b/routes/controller/dynamic-asset.go @@ -4,7 +4,7 @@ import ( "fmt" "net/http" - . "github.com/bctnry/aegis/routes" + . "github.com/GitusCodeForge/Gitus/routes" ) func bindDynamicAssetController(ctx *RouterContext) { diff --git a/routes/controller/history.go b/routes/controller/history.go index 60104d7..3ded29b 100644 --- a/routes/controller/history.go +++ b/routes/controller/history.go @@ -5,12 +5,12 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindHistoryController(ctx *RouterContext) { @@ -103,7 +103,7 @@ func bindHistoryController(ctx *RouterContext) { } m := make(map[string]string, 0) - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { for _, k := range h { m[k.AuthorInfo.AuthorEmail] = "" m[k.CommitterInfo.AuthorEmail] = "" diff --git a/routes/controller/http-clone.go b/routes/controller/http-clone.go index a94943e..c66b9fd 100644 --- a/routes/controller/http-clone.go +++ b/routes/controller/http-clone.go @@ -9,11 +9,11 @@ import ( "os/exec" "path" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" - . "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" + . "github.com/GitusCodeForge/Gitus/routes" ) func printGitError(w io.Writer, s string) { @@ -40,7 +40,7 @@ func bindHttpCloneController(ctx *RouterContext) { fmt.Fprint(w, "HTTP clone not supported on this instance") return } - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { + if ctx.Config.GlobalVisibility != gitus.GLOBAL_VISIBILITY_PUBLIC { ctx.ReportForbidden("", w, r) return } @@ -122,7 +122,7 @@ func bindHttpCloneController(ctx *RouterContext) { fmt.Fprint(w, "v2 protocl not supported on this instance.") return } - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { + if ctx.Config.GlobalVisibility != gitus.GLOBAL_VISIBILITY_PUBLIC { w.WriteHeader(403) w.Write([]byte("Service not available right now.")) return @@ -172,7 +172,7 @@ func bindHttpCloneController(ctx *RouterContext) { http.HandleFunc("GET /repo/{repoName}/HEAD", UseMiddleware( []Middleware{ Logged }, ctx, func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { + if ctx.Config.GlobalVisibility != gitus.GLOBAL_VISIBILITY_PUBLIC { ctx.ReportForbidden("", w, r) return } @@ -214,7 +214,7 @@ func bindHttpCloneController(ctx *RouterContext) { http.HandleFunc("GET /repo/{repoName}/objects/{obj...}", UseMiddleware( []Middleware{ Logged }, ctx, func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility != aegis.GLOBAL_VISIBILITY_PUBLIC { + if ctx.Config.GlobalVisibility != gitus.GLOBAL_VISIBILITY_PUBLIC { ctx.ReportForbidden("", w, r) return } diff --git a/routes/controller/index.go b/routes/controller/index.go index 1ca21ed..149c62e 100644 --- a/routes/controller/index.go +++ b/routes/controller/index.go @@ -6,8 +6,8 @@ import ( "net/http" "strings" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "github.com/gomarkdown/markdown" "github.com/microcosm-cc/bluemonday" "github.com/niklasfasching/go-org/org" diff --git a/routes/controller/init.go b/routes/controller/init.go index 7508308..05fbadf 100644 --- a/routes/controller/init.go +++ b/routes/controller/init.go @@ -1,9 +1,9 @@ package controller import ( - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/routes/controller/admin" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/routes/controller/admin" ) func InitializeRoute(context *routes.RouterContext) { @@ -27,12 +27,12 @@ func InitializeRoute(context *routes.RouterContext) { if context.Config.UseNamespace { bindNamespaceController(context) - if context.Config.OperationMode == aegis.OP_MODE_NORMAL { + if context.Config.OperationMode == gitus.OP_MODE_NORMAL { bindNamespaceSettingController(context) } } - if context.Config.OperationMode == aegis.OP_MODE_NORMAL { + if context.Config.OperationMode == gitus.OP_MODE_NORMAL { bindUserController(context) bindLoginController(context) bindLogoutController(context) diff --git a/routes/controller/issue.go b/routes/controller/issue.go index 71259a8..57b0f92 100644 --- a/routes/controller/issue.go +++ b/routes/controller/issue.go @@ -6,9 +6,9 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindIssueController(ctx *RouterContext) { diff --git a/routes/controller/label.go b/routes/controller/label.go index 7fb7432..369c9b6 100644 --- a/routes/controller/label.go +++ b/routes/controller/label.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindLabelController(ctx *RouterContext) { diff --git a/routes/controller/login.go b/routes/controller/login.go index c911a1a..365b22d 100644 --- a/routes/controller/login.go +++ b/routes/controller/login.go @@ -6,11 +6,11 @@ import ( "strings" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/aegis/session" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus/session" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) @@ -19,7 +19,7 @@ func bindLoginController(ctx *RouterContext) { http.HandleFunc("GET /login", UseMiddleware( []Middleware{Logged, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility == aegis.GLOBAL_VISIBILITY_MAINTENANCE { + if ctx.Config.GlobalVisibility == gitus.GLOBAL_VISIBILITY_MAINTENANCE { FoundAt(w, "/maintenance-notice") return } @@ -37,7 +37,7 @@ func bindLoginController(ctx *RouterContext) { Logged, RateLimit, ValidPOSTRequestRequired, ErrorGuard, }, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { - if rc.Config.GlobalVisibility == aegis.GLOBAL_VISIBILITY_MAINTENANCE { + if rc.Config.GlobalVisibility == gitus.GLOBAL_VISIBILITY_MAINTENANCE { FoundAt(w, "/maintenance-notice") return } @@ -175,7 +175,7 @@ If this isn't you, we advise you to change your password on %s and other platfor http.HandleFunc("GET /login/confirm", UseMiddleware( []Middleware{Logged, RateLimit, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { - if rc.Config.GlobalVisibility == aegis.GLOBAL_VISIBILITY_MAINTENANCE { + if rc.Config.GlobalVisibility == gitus.GLOBAL_VISIBILITY_MAINTENANCE { FoundAt(w, "/maintenance-notice") return } diff --git a/routes/controller/logout.go b/routes/controller/logout.go index 4c80754..7199ab1 100644 --- a/routes/controller/logout.go +++ b/routes/controller/logout.go @@ -4,8 +4,8 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis" - . "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + . "github.com/GitusCodeForge/Gitus/routes" ) @@ -13,7 +13,7 @@ func bindLogoutController(ctx *RouterContext) { http.HandleFunc("GET /logout", UseMiddleware( []Middleware{Logged, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { - if ctx.Config.GlobalVisibility == aegis.GLOBAL_VISIBILITY_MAINTENANCE { + if ctx.Config.GlobalVisibility == gitus.GLOBAL_VISIBILITY_MAINTENANCE { FoundAt(w, "/maintenance-notice") return } diff --git a/routes/controller/maintenance.go b/routes/controller/maintenance.go index d6d2bc2..3c33b48 100644 --- a/routes/controller/maintenance.go +++ b/routes/controller/maintenance.go @@ -3,8 +3,8 @@ package controller import ( "net/http" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindMaintenanceNoticeController(ctx *RouterContext) { diff --git a/routes/controller/namespace-setting.go b/routes/controller/namespace-setting.go index d4377f5..19dd95c 100644 --- a/routes/controller/namespace-setting.go +++ b/routes/controller/namespace-setting.go @@ -6,10 +6,10 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - auxfuncs "github.com/bctnry/aegis/pkg/auxfuncs" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + auxfuncs "github.com/GitusCodeForge/Gitus/pkg/auxfuncs" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindNamespaceSettingController(ctx *RouterContext) { @@ -112,7 +112,7 @@ func bindNamespaceSettingController(ctx *RouterContext) { ) return } - ns.Status = model.AegisNamespaceStatus(i) + ns.Status = model.GitusNamespaceStatus(i) err = rc.DatabaseInterface.UpdateNamespaceInfo(namespaceName, ns) if err != nil { rc.ReportInternalError(err.Error(), w, r) diff --git a/routes/controller/namespace.go b/routes/controller/namespace.go index 71929e9..70d9309 100644 --- a/routes/controller/namespace.go +++ b/routes/controller/namespace.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindNamespaceController(ctx *RouterContext) { @@ -24,7 +24,7 @@ func bindNamespaceController(ctx *RouterContext) { var ns *model.Namespace var ok bool var err error - if rc.Config.OperationMode != aegis.OP_MODE_NORMAL { + if rc.Config.OperationMode != gitus.OP_MODE_NORMAL { ns, ok = rc.GitNamespaceList[namespaceName] if !ok { err = rc.SyncAllNamespacePlain() diff --git a/routes/controller/new-namespace.go b/routes/controller/new-namespace.go index 7d100a6..82ec30e 100644 --- a/routes/controller/new-namespace.go +++ b/routes/controller/new-namespace.go @@ -5,10 +5,10 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindNewNamespaceController(ctx *RouterContext) { diff --git a/routes/controller/new-repository.go b/routes/controller/new-repository.go index c9c845a..95dfb11 100644 --- a/routes/controller/new-repository.go +++ b/routes/controller/new-repository.go @@ -4,9 +4,9 @@ import ( "fmt" "net/http" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) // since we've decided that admin have full power, should we list all diff --git a/routes/controller/new-snippet.go b/routes/controller/new-snippet.go index 0a3e2c8..1bf3359 100644 --- a/routes/controller/new-snippet.go +++ b/routes/controller/new-snippet.go @@ -5,8 +5,8 @@ import ( "net/http" "strconv" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindNewSnippetController(ctx *RouterContext) { diff --git a/routes/controller/private.go b/routes/controller/private.go index 2c3d0e7..48dbcd2 100644 --- a/routes/controller/private.go +++ b/routes/controller/private.go @@ -3,8 +3,8 @@ package controller import ( "net/http" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) diff --git a/routes/controller/receipt.go b/routes/controller/receipt.go index 09b7a7d..536300b 100644 --- a/routes/controller/receipt.go +++ b/routes/controller/receipt.go @@ -5,9 +5,9 @@ import ( "net/http" "time" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/receipt" - . "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + . "github.com/GitusCodeForge/Gitus/routes" ) func bindReceiptController(ctx *RouterContext) { @@ -16,10 +16,10 @@ func bindReceiptController(ctx *RouterContext) { []Middleware{Logged, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { switch rc.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: FoundAt(w, "/maintenance-notice") return - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: FoundAt(w, "/shutdown-notice") return } diff --git a/routes/controller/register.go b/routes/controller/register.go index 2fa0af0..c88d8a3 100644 --- a/routes/controller/register.go +++ b/routes/controller/register.go @@ -5,11 +5,11 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/aegis/receipt" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) @@ -19,10 +19,10 @@ func bindRegisterController(ctx *RouterContext) { []Middleware{Logged, UseLoginInfo, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { switch rc.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: FoundAt(w, "/maintenance-notice") return - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: FoundAt(w, "/shutdown-notice") return } @@ -39,10 +39,10 @@ func bindRegisterController(ctx *RouterContext) { []Middleware{Logged, RateLimit, ValidPOSTRequestRequired, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { switch rc.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: FoundAt(w, "/maintenance-notice") return - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: FoundAt(w, "/shutdown-notice") return } diff --git a/routes/controller/repo-fork.go b/routes/controller/repo-fork.go index 1398a59..cdd76c5 100644 --- a/routes/controller/repo-fork.go +++ b/routes/controller/repo-fork.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindRepositoryForkController(ctx *RouterContext) { diff --git a/routes/controller/repo-pull-request.go b/routes/controller/repo-pull-request.go index ba2ac36..8f6a5c5 100644 --- a/routes/controller/repo-pull-request.go +++ b/routes/controller/repo-pull-request.go @@ -6,11 +6,11 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindRepositoryPullRequestController(ctx *RouterContext) { diff --git a/routes/controller/repo-setting.go b/routes/controller/repo-setting.go index c6f1b31..f181c3d 100644 --- a/routes/controller/repo-setting.go +++ b/routes/controller/repo-setting.go @@ -6,11 +6,11 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/auxfuncs" - "github.com/bctnry/aegis/pkg/gitlib" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/auxfuncs" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindRepositorySettingController(ctx *RouterContext) { @@ -128,7 +128,7 @@ func bindRepositorySettingController(ctx *RouterContext) { return } repo.Description = newDescription - repo.Status = model.AegisRepositoryStatus(i) + repo.Status = model.GitusRepositoryStatus(i) err = ctx.DatabaseInterface.UpdateRepositoryInfo(repo.Namespace, repo.Name, repo) if err != nil { rc.ReportInternalError(fmt.Sprintf("Failed to update repository info: %s", err), w, r) diff --git a/routes/controller/repository.go b/routes/controller/repository.go index 5c30d55..90c7783 100644 --- a/routes/controller/repository.go +++ b/routes/controller/repository.go @@ -6,12 +6,12 @@ import ( "path" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/auxfuncs" - "github.com/bctnry/aegis/pkg/gitlib" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/auxfuncs" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "github.com/gomarkdown/markdown" "github.com/microcosm-cc/bluemonday" "github.com/niklasfasching/go-org/org" @@ -44,7 +44,7 @@ func bindRepositoryController(ctx *RouterContext) { return } - if rc.Config.OperationMode == aegis.OP_MODE_NORMAL { + if rc.Config.OperationMode == gitus.OP_MODE_NORMAL { rc.LoginInfo.IsOwner = s.Owner == rc.LoginInfo.UserName || ns.Owner == rc.LoginInfo.UserName } if !rc.Config.IsInPlainMode() && s.Status == model.REPO_NORMAL_PRIVATE { @@ -123,7 +123,7 @@ func bindRepositoryController(ctx *RouterContext) { // no readme. if !gitlib.IsCommitObject(obj) { goto findingMajorBranchDone; } cobj = obj.(*gitlib.CommitObject) - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { emailUserMap[cobj.AuthorInfo.AuthorEmail] = "" emailUserMap[cobj.CommitterInfo.AuthorEmail] = "" rc.DatabaseInterface.ResolveMultipleEmailToUsername(emailUserMap) @@ -255,7 +255,7 @@ func bindRepositoryController(ctx *RouterContext) { }, )) - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { bindRepositoryForkController(ctx) bindRepositoryPullRequestController(ctx) } diff --git a/routes/controller/reset-password.go b/routes/controller/reset-password.go index dc9686d..8c879b0 100644 --- a/routes/controller/reset-password.go +++ b/routes/controller/reset-password.go @@ -8,11 +8,11 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/aegis/receipt" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) @@ -21,15 +21,15 @@ func bindResetPasswordController(ctx *RouterContext) { []Middleware{Logged, UseLoginInfo, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { switch rc.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: FoundAt(w, "/maintenance-notice") return - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: FoundAt(w, "/shutdown-notice") return } LogTemplateError(rc.LoadTemplate("reset-password-request").Execute(w, struct{ - Config *aegis.AegisConfig + Config *gitus.GitusConfig ErrorMsg string LoginInfo *templates.LoginInfoModel }{ @@ -46,10 +46,10 @@ func bindResetPasswordController(ctx *RouterContext) { }, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { switch rc.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: FoundAt(w, "/maintenance-notice") return - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: FoundAt(w, "/shutdown-notice") return } @@ -109,10 +109,10 @@ If this isn't you, you can simply ignore this message.`, []Middleware{Logged, UseLoginInfo, ErrorGuard}, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { switch rc.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: FoundAt(w, "/maintenance-notice") return - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: FoundAt(w, "/shutdown-notice") return } @@ -137,7 +137,7 @@ If this isn't you, you can simply ignore this message.`, return } LogTemplateError(rc.LoadTemplate("reset-password-update").Execute(w, struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig ReceiptId string LoginInfo *templates.LoginInfoModel }{ @@ -154,10 +154,10 @@ If this isn't you, you can simply ignore this message.`, }, ctx, func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { switch rc.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: FoundAt(w, "/maintenance-notice") return - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: FoundAt(w, "/shutdown-notice") return } diff --git a/routes/controller/rrdoc.go b/routes/controller/rrdoc.go new file mode 100644 index 0000000..62bcd98 --- /dev/null +++ b/routes/controller/rrdoc.go @@ -0,0 +1,94 @@ +package controller + +import ( + "bytes" + "errors" + "fmt" + "net/http" + "os" + "path" + "strings" + + "github.com/GitusCodeForge/Gitus/pkg/gitus" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" + "github.com/gomarkdown/markdown" + + // "github.com/gomarkdown/markdown" + "github.com/microcosm-cc/bluemonday" + "github.com/niklasfasching/go-org/org" +) + +func bindRRDocController(ctx *RouterContext) { + http.HandleFunc("GET /rrdoc/{p}", UseMiddleware( + []Middleware{ Logged, UseLoginInfo }, ctx, + func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { + switch ctx.Config.GlobalVisibility { + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: + FoundAt(w, "/maintenance-notice") + case gitus.GLOBAL_VISIBILITY_PRIVATE: + if !rc.LoginInfo.LoggedIn { + FoundAt(w, "/login") + } + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: + FoundAt(w, "/shutdown-notice") + } + found := false + for _, k := range rc.Config.ReadingRequiredDocument { + if k.Path == r.PathValue("p") { + found = true + } + } + // we don't handle http:// and https:// here because we are to render + // them as direct links to those addresses. + if strings.HasPrefix(r.PathValue("p"), "http://") || + strings.HasPrefix(r.PathValue("p"), "https://") || + !found { + rc.ReportNotFound(r.PathValue("p"), "document", "instance", w, r) + return + } + fp := path.Join(rc.Config.StaticAssetDirectory, "_rrdoc", r.PathValue("p")) + e := path.Ext(fp) + var sourceString string + source, err := os.ReadFile(fp) + if errors.Is(err, os.ErrNotExist) { + sourceString = "(file not found)" + goto _sourceStringRendered + } + if err != nil { + rc.ReportInternalError(err.Error(), w, r) + return + } + switch e { + case ".md": + sourceString = string(markdown.ToHTML(source, nil, nil)) + sourceString = bluemonday.UGCPolicy().Sanitize(sourceString) + case ".org": + doc := org.New().Parse(bytes.NewReader(source), "") + out, err := doc.Write(org.NewHTMLWriter()) + if err != nil { + sourceString = bluemonday.UGCPolicy().Sanitize(string(source)) + sourceString = fmt.Sprintf("
    %s
    ", sourceString) + } else { + sourceString = bluemonday.UGCPolicy().Sanitize(out) + } + case ".htm": fallthrough + case ".html": + sourceString = bluemonday.UGCPolicy().Sanitize(string(source)) + default: + sourceString = bluemonday.UGCPolicy().Sanitize(string(source)) + sourceString = fmt.Sprintf("
    %s
    ", sourceString) + } + _sourceStringRendered: + w.Header().Add("Content-Type", "text/html") + w.WriteHeader(200) + LogTemplateError(rc.LoadTemplate("rrdoc").Execute(w, &templates.RRDocTemplateModel{ + Config: rc.Config, + LoginInfo: rc.LoginInfo, + Title: rc.Config.GetRRDocTitle(r.PathValue("p")), + DocumentContent: sourceString, + })) + }, + )) +} + diff --git a/routes/controller/setting-email.go b/routes/controller/setting-email.go index c7af99a..afa3c4b 100644 --- a/routes/controller/setting-email.go +++ b/routes/controller/setting-email.go @@ -4,9 +4,9 @@ import ( "fmt" "net/http" - "github.com/bctnry/aegis/pkg/aegis/receipt" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindSettingEmailController(ctx *RouterContext) { diff --git a/routes/controller/setting-gpg.go b/routes/controller/setting-gpg.go index 636493f..f97d110 100644 --- a/routes/controller/setting-gpg.go +++ b/routes/controller/setting-gpg.go @@ -5,10 +5,10 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/auxfuncs" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/auxfuncs" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindSettingGPGController(ctx *RouterContext) { diff --git a/routes/controller/setting-privacy.go b/routes/controller/setting-privacy.go index 69207fb..89fd860 100644 --- a/routes/controller/setting-privacy.go +++ b/routes/controller/setting-privacy.go @@ -5,8 +5,8 @@ import ( "net/http" "strings" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) diff --git a/routes/controller/setting-ssh.go b/routes/controller/setting-ssh.go index ee55555..f22553f 100644 --- a/routes/controller/setting-ssh.go +++ b/routes/controller/setting-ssh.go @@ -5,10 +5,10 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/auxfuncs" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/auxfuncs" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) diff --git a/routes/controller/setting-user-info.go b/routes/controller/setting-user-info.go index 462452e..3d73c42 100644 --- a/routes/controller/setting-user-info.go +++ b/routes/controller/setting-user-info.go @@ -4,10 +4,10 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" "golang.org/x/crypto/bcrypt" ) diff --git a/routes/controller/shutdown.go b/routes/controller/shutdown.go index d4d100a..3666d98 100644 --- a/routes/controller/shutdown.go +++ b/routes/controller/shutdown.go @@ -3,8 +3,8 @@ package controller import ( "net/http" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) diff --git a/routes/controller/snippet.go b/routes/controller/snippet.go index 74b90c2..fadb2c6 100644 --- a/routes/controller/snippet.go +++ b/routes/controller/snippet.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func bindSnippetController(ctx *RouterContext) { diff --git a/routes/controller/tag.go b/routes/controller/tag.go index 0d4ad65..a3f8242 100644 --- a/routes/controller/tag.go +++ b/routes/controller/tag.go @@ -7,12 +7,12 @@ import ( "path" "strings" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func handleTagSnapshotRequest(repo *model.Repository, branchName string, obj gitlib.GitObject, w http.ResponseWriter) error { @@ -207,7 +207,7 @@ func bindTagController(ctx *RouterContext) { ) return } - if rc.Config.OperationMode == aegis.OP_MODE_NORMAL { + if rc.Config.OperationMode == gitus.OP_MODE_NORMAL { m, _ = rc.DatabaseInterface.ResolveMultipleEmailToUsername(m) } tagInfo.EmailUserMapping = m @@ -238,7 +238,7 @@ func bindTagController(ctx *RouterContext) { str := string(bobj.Data) coloredStr, err := colorSyntax("", str) if err == nil { str = coloredStr } - if rc.Config.OperationMode == aegis.OP_MODE_NORMAL { + if rc.Config.OperationMode == gitus.OP_MODE_NORMAL { m, _ = rc.DatabaseInterface.ResolveMultipleEmailToUsername(m) } tagInfo.EmailUserMapping = m @@ -281,7 +281,7 @@ func bindTagController(ctx *RouterContext) { TreePath: treePath, TreePathSegmentList: treePathSegmentList, } - if rc.Config.OperationMode == aegis.OP_MODE_NORMAL { + if rc.Config.OperationMode == gitus.OP_MODE_NORMAL { m, _ = rc.DatabaseInterface.ResolveMultipleEmailToUsername(m) } commitInfo.EmailUserMapping = m diff --git a/routes/controller/tree.go b/routes/controller/tree.go index 132187b..d01bcde 100644 --- a/routes/controller/tree.go +++ b/routes/controller/tree.go @@ -5,11 +5,11 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/pkg/gitlib" - "github.com/bctnry/aegis/routes" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/pkg/gitlib" + "github.com/GitusCodeForge/Gitus/routes" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) func handleTreeSnapshotRequest(repo *model.Repository, treeId string, obj gitlib.GitObject, w http.ResponseWriter) { diff --git a/routes/controller/user.go b/routes/controller/user.go index 9822ebf..b08095d 100644 --- a/routes/controller/user.go +++ b/routes/controller/user.go @@ -6,10 +6,10 @@ import ( "strconv" "strings" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" + "github.com/GitusCodeForge/Gitus/templates" ) diff --git a/routes/controller/verify-email.go b/routes/controller/verify-email.go index 70112cc..55d776d 100644 --- a/routes/controller/verify-email.go +++ b/routes/controller/verify-email.go @@ -5,9 +5,9 @@ import ( "net/http" "strings" - "github.com/bctnry/aegis/pkg/aegis/receipt" - "github.com/bctnry/aegis/routes" - . "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" + "github.com/GitusCodeForge/Gitus/routes" + . "github.com/GitusCodeForge/Gitus/routes" ) func bindVerifyEmailController(ctx *routes.RouterContext) { diff --git a/routes/controller/webhook-result-report.go b/routes/controller/webhook-result-report.go index 4edd326..9af19cd 100644 --- a/routes/controller/webhook-result-report.go +++ b/routes/controller/webhook-result-report.go @@ -10,9 +10,9 @@ import ( "regexp" "time" - "github.com/bctnry/aegis/pkg/aegis/db" - "github.com/bctnry/aegis/pkg/aegis/model" - . "github.com/bctnry/aegis/routes" + "github.com/GitusCodeForge/Gitus/pkg/gitus/db" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + . "github.com/GitusCodeForge/Gitus/routes" "github.com/golang-jwt/jwt/v5" ) diff --git a/routes/middleware.go b/routes/middleware.go index 03c452a..d6b9e60 100644 --- a/routes/middleware.go +++ b/routes/middleware.go @@ -6,9 +6,9 @@ import ( "net/http" "slices" - "github.com/bctnry/aegis/pkg/aegis" - "github.com/bctnry/aegis/pkg/aegis/model" - "github.com/bctnry/aegis/templates" + "github.com/GitusCodeForge/Gitus/pkg/gitus" + "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + "github.com/GitusCodeForge/Gitus/templates" ) // middleware... @@ -61,7 +61,7 @@ var JSONRequestRequired Middleware = func(f HandlerFunc) HandlerFunc { var UseLoginInfo Middleware = func(f HandlerFunc) HandlerFunc { return func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { ctx.LoginInfo, ctx.LastError = GenerateLoginInfoModel(ctx, r) } f(ctx, w, r) @@ -70,7 +70,7 @@ var UseLoginInfo Middleware = func(f HandlerFunc) HandlerFunc { var LoginRequired Middleware = func(f HandlerFunc) HandlerFunc { return func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { ctx.LoginInfo, ctx.LastError = GenerateLoginInfoModel(ctx, r) if ctx.LastError != nil { ctx.ReportRedirect("/login", 0, "Login Check Failed", fmt.Sprintf("Failed while checking login status: %s.", ctx.LastError), w, r) @@ -87,7 +87,7 @@ var LoginRequired Middleware = func(f HandlerFunc) HandlerFunc { var AdminRequired Middleware = func(f HandlerFunc) HandlerFunc { return func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL { + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL { if ctx.LoginInfo == nil { ctx.LoginInfo, ctx.LastError = GenerateLoginInfoModel(ctx, r) if ctx.LastError != nil { @@ -132,13 +132,13 @@ func ValidRepositoryNameRequired(s string) Middleware { func CheckGlobalVisibleToUser(ctx *RouterContext, loginInfo *templates.LoginInfoModel) bool { if ctx.Config.IsInPlainMode() { return true } - if ctx.Config.OperationMode == aegis.OP_MODE_NORMAL && loginInfo == nil { return false } + if ctx.Config.OperationMode == gitus.OP_MODE_NORMAL && loginInfo == nil { return false } switch ctx.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_PUBLIC: return true - case aegis.GLOBAL_VISIBILITY_PRIVATE: return loginInfo.LoggedIn - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_PUBLIC: return true + case gitus.GLOBAL_VISIBILITY_PRIVATE: return loginInfo.LoggedIn + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: return slices.Contains(ctx.Config.FullAccessUser, loginInfo.UserName) - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: return false + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: return false default: return false } } @@ -147,13 +147,13 @@ var GlobalVisibility Middleware = func(f HandlerFunc) HandlerFunc { return func(ctx *RouterContext, w http.ResponseWriter, r *http.Request) { if !CheckGlobalVisibleToUser(ctx, ctx.LoginInfo) { switch ctx.Config.GlobalVisibility { - case aegis.GLOBAL_VISIBILITY_MAINTENANCE: + case gitus.GLOBAL_VISIBILITY_MAINTENANCE: FoundAt(w, "/maintenance-notice") return - case aegis.GLOBAL_VISIBILITY_SHUTDOWN: + case gitus.GLOBAL_VISIBILITY_SHUTDOWN: FoundAt(w, "/shutdown-notice") return - case aegis.GLOBAL_VISIBILITY_PRIVATE: + case gitus.GLOBAL_VISIBILITY_PRIVATE: FoundAt(w, "/login") return } @@ -174,7 +174,7 @@ var RateLimit Middleware = func(f HandlerFunc) HandlerFunc { var NormalModeRequired Middleware = func(f HandlerFunc) HandlerFunc { return func(rc *RouterContext, w http.ResponseWriter, r *http.Request) { - if rc.Config.OperationMode != aegis.OP_MODE_NORMAL { + if rc.Config.OperationMode != gitus.OP_MODE_NORMAL { w.WriteHeader(404) } else { f(rc, w, r) diff --git a/routes/ratelimiter.go b/routes/ratelimiter.go index 399a319..3f40f58 100644 --- a/routes/ratelimiter.go +++ b/routes/ratelimiter.go @@ -6,7 +6,7 @@ import ( "strings" "sync" - "github.com/bctnry/aegis/pkg/aegis" + "github.com/GitusCodeForge/Gitus/pkg/gitus" "golang.org/x/time/rate" ) @@ -17,7 +17,7 @@ type RateLimiter struct { cap int } -func NewRateLimiter(cfg *aegis.AegisConfig) *RateLimiter { +func NewRateLimiter(cfg *gitus.GitusConfig) *RateLimiter { return &RateLimiter{ limiter: make(map[string]*rate.Limiter, 0), mutex: &sync.RWMutex{}, diff --git a/templates/_commit-info.model.go b/templates/_commit-info.model.go index 233bb58..c746756 100644 --- a/templates/_commit-info.model.go +++ b/templates/_commit-info.model.go @@ -2,7 +2,7 @@ package templates -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type CommitInfoTemplateModel struct { RootPath string diff --git a/templates/_footer.template.html b/templates/_footer.template.html index 8612749..c6b8126 100644 --- a/templates/_footer.template.html +++ b/templates/_footer.template.html @@ -1,6 +1,6 @@ {{define "_footer"}} {{end}} \ No newline at end of file diff --git a/templates/_redirect/index.model.go b/templates/_redirect/index.model.go index 6abfd04..5b43451 100644 --- a/templates/_redirect/index.model.go +++ b/templates/_redirect/index.model.go @@ -3,7 +3,7 @@ package templates type RedirectWithMessageModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg string Timeout int diff --git a/templates/_repo-header.model.go b/templates/_repo-header.model.go index ddd7cdc..491bbe9 100644 --- a/templates/_repo-header.model.go +++ b/templates/_repo-header.model.go @@ -1,8 +1,8 @@ //go:build ignore package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepoHeaderTemplateModel struct { TypeStr string diff --git a/templates/_tag-info.model.go b/templates/_tag-info.model.go index 47b3b8f..e3abdcb 100644 --- a/templates/_tag-info.model.go +++ b/templates/_tag-info.model.go @@ -2,7 +2,7 @@ package templates -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type TagInfoTemplateModel struct { // it should be made sure that when Annotated is true, Tag is nil, diff --git a/templates/admin/_config.model.go b/templates/admin/_config.model.go index fb904c1..9366fd2 100644 --- a/templates/admin/_config.model.go +++ b/templates/admin/_config.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminConfigTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg string } diff --git a/templates/admin/index.model.go b/templates/admin/index.model.go index 2f9ecd2..831e605 100644 --- a/templates/admin/index.model.go +++ b/templates/admin/index.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminIndexTemplateModel struct { - Config *aegis.AegisConfig - User *model.AegisUser + Config *gitus.GitusConfig + User *model.GitusUser LoginInfo *LoginInfoModel ErrorMsg struct{ Type string diff --git a/templates/admin/namespace-edit.model.go b/templates/admin/namespace-edit.model.go index ca3746c..0e66320 100644 --- a/templates/admin/namespace-edit.model.go +++ b/templates/admin/namespace-edit.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminNamespaceEditTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Namespace *model.Namespace ErrorMsg struct { Type string diff --git a/templates/admin/namespace-list.model.go b/templates/admin/namespace-list.model.go index bb566e9..c17d9e5 100644 --- a/templates/admin/namespace-list.model.go +++ b/templates/admin/namespace-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminNamespaceListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg string NamespaceList map[string]*model.Namespace diff --git a/templates/admin/receipt-list.model.go b/templates/admin/receipt-list.model.go index e7ab06a..d045192 100644 --- a/templates/admin/receipt-list.model.go +++ b/templates/admin/receipt-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/receipt" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/receipt" type AdminReceiptListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg string ReceiptList []*receipt.Receipt diff --git a/templates/admin/registration-request.model.go b/templates/admin/registration-request.model.go index 0d36a17..547c3b1 100644 --- a/templates/admin/registration-request.model.go +++ b/templates/admin/registration-request.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminRegistrationRequestTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg string RequestList []*model.RegistrationRequest diff --git a/templates/admin/repo-list.model.go b/templates/admin/repo-list.model.go index 468dcba..1484291 100644 --- a/templates/admin/repo-list.model.go +++ b/templates/admin/repo-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminRepositoryListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg string RepositoryList []*model.Repository diff --git a/templates/admin/rrdoc/edit.model.go b/templates/admin/rrdoc/edit.model.go new file mode 100644 index 0000000..cecd176 --- /dev/null +++ b/templates/admin/rrdoc/edit.model.go @@ -0,0 +1,17 @@ +//go:build ignore + +package templates + + +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + +type AdminRRDocEditTemplateModel struct { + Config *gitus.GitusConfig + LoginInfo *LoginInfoModel + DocumentNumber int + Title string + Path string + Content string +} + diff --git a/templates/admin/rrdoc/edit.template.html b/templates/admin/rrdoc/edit.template.html new file mode 100644 index 0000000..75e8b14 --- /dev/null +++ b/templates/admin/rrdoc/edit.template.html @@ -0,0 +1,52 @@ + + + + + Codestin Search App + + + + + + + +
    + {{template "_header-nav" .}} + +

    Admin/RRDoc

    +
    +
    + +
    + {{template "_admin-sidebar" .}} + +
    +

    {{if eq .DocumentNumber -1}}Add New Document{{else}}Edit Document #{{.DocumentNumber}}{{end}}

    + + + +
    + + +
    +
    + + +
    +
    + + +
    + + + +
    +
    + +
    +
    + {{template "_footer"}} +
    + + + diff --git a/templates/admin/rrdoc/list.model.go b/templates/admin/rrdoc/list.model.go new file mode 100644 index 0000000..fc82c59 --- /dev/null +++ b/templates/admin/rrdoc/list.model.go @@ -0,0 +1,13 @@ +//go:build ignore + +package templates + + +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" + +type AdminRRDocListTemplateModel struct { + Config *gitus.GitusConfig + LoginInfo *LoginInfoModel +} + diff --git a/templates/admin/rrdoc/list.template.html b/templates/admin/rrdoc/list.template.html new file mode 100644 index 0000000..adc4c48 --- /dev/null +++ b/templates/admin/rrdoc/list.template.html @@ -0,0 +1,53 @@ + + + + + Codestin Search App + + + + + + + +
    + {{template "_header-nav" .}} + +

    Admin/RRDoc

    +
    +
    + +
    + {{template "_admin-sidebar"}} + +
    +

    Legal document list

    +
    + These are documents that are required for user to read & consent to before registering. +
    + Add New Document + + + + + + {{range $k, $v := .Config.ReadingRequiredDocument}} + + + + + + + {{end}} + +
    TitlePathEditDelete
    {{$v.Title}}{{$v.Path}}EditDelete
    +
    +
    + +
    +
    + {{template "_footer"}} +
    + + + diff --git a/templates/admin/site-lockdown.model.go b/templates/admin/site-lockdown.model.go index 3d4b30c..309dbe2 100644 --- a/templates/admin/site-lockdown.model.go +++ b/templates/admin/site-lockdown.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminSiteLockdownTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel CurrentMode string PrivateNoticeMessage string diff --git a/templates/admin/user-list.model.go b/templates/admin/user-list.model.go index 4c07fc0..bc620e9 100644 --- a/templates/admin/user-list.model.go +++ b/templates/admin/user-list.model.go @@ -2,14 +2,14 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminUserListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg string - UserList []*model.AegisUser + UserList []*model.GitusUser PageInfo *PageInfoModel } diff --git a/templates/admin/user/edit-gpg-key.model.go b/templates/admin/user/edit-gpg-key.model.go index 775aec3..767e85b 100644 --- a/templates/admin/user/edit-gpg-key.model.go +++ b/templates/admin/user/edit-gpg-key.model.go @@ -2,13 +2,13 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type SettingEditGPGKeyTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel - Key *model.AegisSigningKey + Key *model.GitusSigningKey ErrorMsg struct{ Type string Message string diff --git a/templates/admin/user/edit-ssh-key.model.go b/templates/admin/user/edit-ssh-key.model.go index 1ccf770..1ebcf46 100644 --- a/templates/admin/user/edit-ssh-key.model.go +++ b/templates/admin/user/edit-ssh-key.model.go @@ -2,13 +2,13 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type SettingEditSSHKeyTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel - Key *model.AegisAuthKey + Key *model.GitusAuthKey ErrorMsg struct{ Type string Message string diff --git a/templates/admin/user/edit.model.go b/templates/admin/user/edit.model.go index 5442d04..cbcee24 100644 --- a/templates/admin/user/edit.model.go +++ b/templates/admin/user/edit.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminUserEditTemplateModel struct { - Config *aegis.AegisConfig - User *model.AegisUser + Config *gitus.GitusConfig + User *model.GitusUser ErrorMsg struct { Type string Message string diff --git a/templates/admin/user/gpg-key.model.go b/templates/admin/user/gpg-key.model.go index de1df6e..2e4b5a1 100644 --- a/templates/admin/user/gpg-key.model.go +++ b/templates/admin/user/gpg-key.model.go @@ -2,14 +2,14 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminUserGPGKeyTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel - User *model.AegisUser - KeyList []model.AegisSigningKey + User *model.GitusUser + KeyList []model.GitusSigningKey ErrorMsg struct{ Type string Message string diff --git a/templates/admin/user/ssh-key.model.go b/templates/admin/user/ssh-key.model.go index 4d9ea19..4bdeb85 100644 --- a/templates/admin/user/ssh-key.model.go +++ b/templates/admin/user/ssh-key.model.go @@ -2,14 +2,14 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminUserSSHKeyTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel - User *model.AegisUser - KeyList []model.AegisAuthKey + User *model.GitusUser + KeyList []model.GitusAuthKey ErrorMsg struct{ Type string Message string diff --git a/templates/all/namespace-list.model.go b/templates/all/namespace-list.model.go index 593f49b..cf7ac6c 100644 --- a/templates/all/namespace-list.model.go +++ b/templates/all/namespace-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AllNamespaceListModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig DepotName string NamespaceList map[string]*model.Namespace LoginInfo *LoginInfoModel diff --git a/templates/all/repository-list.model.go b/templates/all/repository-list.model.go index dd1315e..bbdb89a 100644 --- a/templates/all/repository-list.model.go +++ b/templates/all/repository-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AllRepositoryListModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig RepositoryList []*model.Repository DepotName string LoginInfo *LoginInfoModel diff --git a/templates/commit-history.model.go b/templates/commit-history.model.go index 0511d26..37f5347 100644 --- a/templates/commit-history.model.go +++ b/templates/commit-history.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type CommitHistoryModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel Commit gitlib.CommitObject diff --git a/templates/depot-namespace.model.go b/templates/depot-namespace.model.go index 8ef3750..48d4000 100644 --- a/templates/depot-namespace.model.go +++ b/templates/depot-namespace.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type DepotNamespaceModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig DepotName string NamespaceList map[string]*model.Namespace LoginInfo *LoginInfoModel diff --git a/templates/depot-no-namespace.model.go b/templates/depot-no-namespace.model.go index 80b8875..0c59d16 100644 --- a/templates/depot-no-namespace.model.go +++ b/templates/depot-no-namespace.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type DepotNoNamespaceModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig RepositoryList []struct{RelPath string; Description string} DepotName string LoginInfo *LoginInfoModel diff --git a/templates/diff.model.go b/templates/diff.model.go index 13b5a2a..ca03f2e 100644 --- a/templates/diff.model.go +++ b/templates/diff.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type DiffTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel CommitInfo CommitInfoTemplateModel diff --git a/templates/edit-file.model.go b/templates/edit-file.model.go index ca6d865..67319e8 100644 --- a/templates/edit-file.model.go +++ b/templates/edit-file.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type EditFileTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel PermaLink string diff --git a/templates/error.model.go b/templates/error.model.go index eccbe5b..b140431 100644 --- a/templates/error.model.go +++ b/templates/error.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type ErrorTemplateModel struct{ - Config *aegis.AegisConfig + Config *gitus.GitusConfig ErrorCode int ErrorMessage string LoginInfo *LoginInfoModel diff --git a/templates/file.model.go b/templates/file.model.go index a6a8279..3c10ac8 100644 --- a/templates/file.model.go +++ b/templates/file.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type FileTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel File BlobTextTemplateModel diff --git a/templates/fork.model.go b/templates/fork.model.go index 1ead329..9364d54 100644 --- a/templates/fork.model.go +++ b/templates/fork.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type ForkTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel SourceRepository *model.Repository ForkedRepoList []*model.Repository diff --git a/templates/getRRDocHref.func.go b/templates/getRRDocHref.func.go new file mode 100644 index 0000000..771f064 --- /dev/null +++ b/templates/getRRDocHref.func.go @@ -0,0 +1,16 @@ +//go:build ignore +package templates + +import "fmt" +import "strings" + +func(s string) string { + if strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://") { + return s + } else { + return fmt.Sprintf("/rrdoc/%s", s) + } +} + + + diff --git a/templates/getRepoSSH.func.go b/templates/getRepoSSH.func.go index 8ec5091..a624353 100644 --- a/templates/getRepoSSH.func.go +++ b/templates/getRepoSSH.func.go @@ -2,11 +2,11 @@ package templates import "fmt" -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" -func(cfg aegis.AegisConfig, repo model.Repository) string { +func(cfg gitus.GitusConfig, repo model.Repository) string { gitSshHostName := cfg.GitSSHHostName() sshfn := fmt.Sprintf("%s/%s", repo.Namespace, repo.Name) return fmt.Sprintf("%s%s", gitSshHostName, sshfn) diff --git a/templates/rrdoc.model.go b/templates/rrdoc.model.go new file mode 100644 index 0000000..546e304 --- /dev/null +++ b/templates/rrdoc.model.go @@ -0,0 +1,13 @@ +//go:build ignore + +package templates + +import "github.com/GitusCodeForge/Gitus/pkg/gitus" + +type RRDocTemplateModel struct { + Config *gitus.GitusConfig + LoginInfo *LoginInfoModel + Title string + DocumentContent string +} + diff --git a/templates/rrdoc.template.html b/templates/rrdoc.template.html new file mode 100644 index 0000000..8bfc0b8 --- /dev/null +++ b/templates/rrdoc.template.html @@ -0,0 +1,23 @@ + + + + + Codestin Search App + + + + + +
    + {{template "_header-nav" .}} +

    {{.Title}}

    +
    +
    + {{rawHTML .DocumentContent}} +
    +
    + {{template "_footer"}} +
    + + + diff --git a/templates/snippet/setting.model.go b/templates/snippet/setting.model.go index 6a4537d..92df476 100644 --- a/templates/snippet/setting.model.go +++ b/templates/snippet/setting.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type SnippetSettingTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel Snippet *model.Snippet } diff --git a/templates/tag.model.go b/templates/tag.model.go index 15e289f..fb27434 100644 --- a/templates/tag.model.go +++ b/templates/tag.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type TagTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel Tag *gitlib.TagObject diff --git a/templates/toFuzzyTime.func.go b/templates/toFuzzyTime.func.go index 9830c8b..1c688be 100644 --- a/templates/toFuzzyTime.func.go +++ b/templates/toFuzzyTime.func.go @@ -3,7 +3,7 @@ package templates import "fmt" import "time" -import "github.com/bctnry/aegis/pkg/fuzzytime" +import "github.com/GitusCodeForge/Gitus/pkg/fuzzytime" // this is used to escape urls in html attribute values. diff --git a/templates/tree.model.go b/templates/tree.model.go index 2678f0c..aac70ee 100644 --- a/templates/tree.model.go +++ b/templates/tree.model.go @@ -1,11 +1,11 @@ //go:build ignore package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type TreeTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel TreeFileList *TreeFileListTemplateModel diff --git a/templates/upload-file.model.go b/templates/upload-file.model.go index 9384af9..cc772c4 100644 --- a/templates/upload-file.model.go +++ b/templates/upload-file.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type UploadFileTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel PermaLink string diff --git a/templates/user-snippet-list.model.go b/templates/user-snippet-list.model.go index 3e850ee..93b219a 100644 --- a/templates/user-snippet-list.model.go +++ b/templates/user-snippet-list.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type UserSnippetListTemplateModel struct { - Config *aegis.AegisConfig - User *model.AegisUser + Config *gitus.GitusConfig + User *model.GitusUser SnippetList []*model.Snippet LoginInfo *LoginInfoModel BelongingNamespaceList []*model.Namespace diff --git a/templates/user.model.go b/templates/user.model.go index 542d70b..b9140e6 100644 --- a/templates/user.model.go +++ b/templates/user.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type UserTemplateModel struct { - Config *aegis.AegisConfig - User *model.AegisUser + Config *gitus.GitusConfig + User *model.GitusUser RepositoryList []*model.Repository LoginInfo *LoginInfoModel BelongingNamespaceList []*model.Namespace diff --git a/templates/webinstaller/webinstaller.model.go b/templates/webinstaller/webinstaller.model.go index 143bce5..b0098a3 100644 --- a/templates/webinstaller/webinstaller.model.go +++ b/templates/webinstaller/webinstaller.model.go @@ -2,10 +2,10 @@ package webinstaller -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type WebInstallerTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig RootSSHKey string ConfirmStageReached bool } From 89975c03a7dd50a6086090b400e28b8c9e841641 Mon Sep 17 00:00:00 2001 From: Sebastian Zack Tin Lahm-Lee Date: Fri, 30 Jan 2026 02:13:33 +0800 Subject: [PATCH 19/19] refactor: name change, part 2 --- templates/getRepoURL.func.go | 6 +++--- templates/git-blame.model.go | 4 ++-- templates/index-static.model.go | 4 ++-- templates/isFork.func.go | 2 +- templates/issue/issue-list.model.go | 6 +++--- templates/issue/new-issue.model.go | 6 +++--- templates/issue/single-issue.model.go | 6 +++--- templates/label.model.go | 6 +++--- templates/login-confirm.model.go | 4 ++-- templates/login.model.go | 4 ++-- templates/maintenance-notice.model.go | 4 ++-- templates/namespace-setting/change-info.model.go | 6 +++--- templates/namespace-setting/edit-member.model.go | 6 +++--- templates/namespace-setting/member-list.model.go | 6 +++--- templates/namespace.model.go | 6 +++--- templates/new-file.model.go | 4 ++-- templates/new/namespace.model.go | 8 ++++---- templates/new/repository.model.go | 6 +++--- templates/new/snippet.model.go | 6 +++--- templates/parseMergeCheckResult.func.go | 2 +- templates/private-notice.model.go | 4 ++-- templates/pull-request/new-pull-request.model.go | 6 +++--- templates/pull-request/pull-request-list.model.go | 6 +++--- templates/pull-request/single-pull-request.model.go | 6 +++--- templates/registration.model.go | 4 ++-- templates/renderACLTuple.func.go | 2 +- templates/repo-setting/change-info.model.go | 6 +++--- templates/repo-setting/edit-label.model.go | 6 +++--- templates/repo-setting/edit-member.model.go | 6 +++--- templates/repo-setting/edit-webhook.model.go | 6 +++--- templates/repo-setting/hook-list.model.go | 6 +++--- templates/repo-setting/member-list.model.go | 6 +++--- templates/repository.model.go | 6 +++--- templates/retrieveCommentOnCode.func.go | 8 ++++---- templates/setting/edit-gpg-key.model.go | 10 +++++----- templates/setting/edit-ssh-key.model.go | 10 +++++----- templates/setting/email.model.go | 6 +++--- templates/setting/gpg-key.model.go | 8 ++++---- templates/setting/privacy.model.go | 8 ++++---- templates/setting/ssh-key.model.go | 8 ++++---- templates/setting/user-info.model.go | 8 ++++---- templates/shouldShowSynchronizeLink.func.go | 2 +- templates/shutdown-notice.model.go | 4 ++-- templates/snippet/all-file.model.go | 8 ++++---- templates/snippet/edit-file.model.go | 8 ++++---- templates/snippet/new-file.model.go | 8 ++++---- 46 files changed, 134 insertions(+), 134 deletions(-) diff --git a/templates/getRepoURL.func.go b/templates/getRepoURL.func.go index e91e6ae..ba13b15 100644 --- a/templates/getRepoURL.func.go +++ b/templates/getRepoURL.func.go @@ -2,11 +2,11 @@ package templates import "fmt" -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" -func(cfg aegis.AegisConfig, repo model.Repository) string { +func(cfg gitus.GitusConfig, repo model.Repository) string { httpHostName := cfg.ProperHTTPHostName() rfn := repo.FullName() return fmt.Sprintf("%s/repo/%s", httpHostName, rfn) diff --git a/templates/git-blame.model.go b/templates/git-blame.model.go index 53fca7d..a1ea9ef 100644 --- a/templates/git-blame.model.go +++ b/templates/git-blame.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/bctnry/gitus/pkg/gitus" type GitBlameTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel Blame *gitlib.PorcelainBlame diff --git a/templates/index-static.model.go b/templates/index-static.model.go index a9ce7db..001b2a3 100644 --- a/templates/index-static.model.go +++ b/templates/index-static.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type IndexStaticTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel FrontPage string } diff --git a/templates/isFork.func.go b/templates/isFork.func.go index 3882906..b72dc87 100644 --- a/templates/isFork.func.go +++ b/templates/isFork.func.go @@ -1,7 +1,7 @@ //go:build ignore package templates -import "github.com/bctnry/aegis/pkg/model" +import "github.com/GitusCodeForge/Gitus/pkg/model" func(s *model.Repository) bool { return len(s.ForkOriginNamespace) > 0 && len(s.ForkOriginName) >0 diff --git a/templates/issue/issue-list.model.go b/templates/issue/issue-list.model.go index 8cbd5e7..9b308c1 100644 --- a/templates/issue/issue-list.model.go +++ b/templates/issue/issue-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositoryIssueListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel LoginInfo *LoginInfoModel diff --git a/templates/issue/new-issue.model.go b/templates/issue/new-issue.model.go index 765d091..621cb9f 100644 --- a/templates/issue/new-issue.model.go +++ b/templates/issue/new-issue.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositoryNewIssueTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel LoginInfo *LoginInfoModel diff --git a/templates/issue/single-issue.model.go b/templates/issue/single-issue.model.go index 377a68f..d34c23b 100644 --- a/templates/issue/single-issue.model.go +++ b/templates/issue/single-issue.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositorySingleIssueTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel LoginInfo *LoginInfoModel diff --git a/templates/label.model.go b/templates/label.model.go index 2864389..f31d50e 100644 --- a/templates/label.model.go +++ b/templates/label.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type LabelModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig RepositoryList []*model.Repository LoginInfo *LoginInfoModel PageInfo *PageInfoModel diff --git a/templates/login-confirm.model.go b/templates/login-confirm.model.go index ecf3fe5..93534ef 100644 --- a/templates/login-confirm.model.go +++ b/templates/login-confirm.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type LoginConfirmTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig ErrorMsg string LoginInfo *LoginInfoModel Username string diff --git a/templates/login.model.go b/templates/login.model.go index 1f11ba4..85658b3 100644 --- a/templates/login.model.go +++ b/templates/login.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type LoginTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig ErrorMsg string LoginInfo *LoginInfoModel Callback string diff --git a/templates/maintenance-notice.model.go b/templates/maintenance-notice.model.go index 9bf94f3..8a505a3 100644 --- a/templates/maintenance-notice.model.go +++ b/templates/maintenance-notice.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type MaintenanceNoticeTemplateModel struct{ - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel Message string } diff --git a/templates/namespace-setting/change-info.model.go b/templates/namespace-setting/change-info.model.go index 7b41c78..65210c1 100644 --- a/templates/namespace-setting/change-info.model.go +++ b/templates/namespace-setting/change-info.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type NamespaceSettingTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Namespace *model.Namespace LoginInfo *LoginInfoModel ErrorMsg struct { diff --git a/templates/namespace-setting/edit-member.model.go b/templates/namespace-setting/edit-member.model.go index 5cd3ef0..8d9a53b 100644 --- a/templates/namespace-setting/edit-member.model.go +++ b/templates/namespace-setting/edit-member.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type NamespaceSettingEditMemberTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Namespace *model.Namespace LoginInfo *LoginInfoModel ErrorMsg string diff --git a/templates/namespace-setting/member-list.model.go b/templates/namespace-setting/member-list.model.go index 38e7ebe..c17fbdd 100644 --- a/templates/namespace-setting/member-list.model.go +++ b/templates/namespace-setting/member-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type NamespaceSettingMemberListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Namespace *model.Namespace LoginInfo *LoginInfoModel ErrorMsg string diff --git a/templates/namespace.model.go b/templates/namespace.model.go index bed8eab..cb3f289 100644 --- a/templates/namespace.model.go +++ b/templates/namespace.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type NamespaceTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Namespace *model.Namespace LoginInfo *LoginInfoModel } diff --git a/templates/new-file.model.go b/templates/new-file.model.go index 2410436..37d12e1 100644 --- a/templates/new-file.model.go +++ b/templates/new-file.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type NewFileTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel PermaLink string diff --git a/templates/new/namespace.model.go b/templates/new/namespace.model.go index 9fd10c5..03565df 100644 --- a/templates/new/namespace.model.go +++ b/templates/new/namespace.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type NewNamespaceTemplateModel struct { - Config *aegis.AegisConfig - User *model.AegisUser + Config *gitus.GitusConfig + User *model.GitusUser LoginInfo *LoginInfoModel ErrorMsg struct{ Type string diff --git a/templates/new/repository.model.go b/templates/new/repository.model.go index 90701f1..380b803 100644 --- a/templates/new/repository.model.go +++ b/templates/new/repository.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type NewRepositoryTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg struct{ Type string diff --git a/templates/new/snippet.model.go b/templates/new/snippet.model.go index 5922776..0ff2ce0 100644 --- a/templates/new/snippet.model.go +++ b/templates/new/snippet.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type NewSnippetTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel ErrorMsg struct{ Type string diff --git a/templates/parseMergeCheckResult.func.go b/templates/parseMergeCheckResult.func.go index 4584d38..6ed63e4 100644 --- a/templates/parseMergeCheckResult.func.go +++ b/templates/parseMergeCheckResult.func.go @@ -2,7 +2,7 @@ package templates import "encoding/json" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" func(s string) *gitlib.MergeCheckResult { var r *gitlib.MergeCheckResult diff --git a/templates/private-notice.model.go b/templates/private-notice.model.go index fdbeac8..3a948b3 100644 --- a/templates/private-notice.model.go +++ b/templates/private-notice.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type PrivateNoticeTemplateModel struct{ - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel Message string } diff --git a/templates/pull-request/new-pull-request.model.go b/templates/pull-request/new-pull-request.model.go index fba07ce..a323b34 100644 --- a/templates/pull-request/new-pull-request.model.go +++ b/templates/pull-request/new-pull-request.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositoryNewPullRequestTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel LoginInfo *LoginInfoModel diff --git a/templates/pull-request/pull-request-list.model.go b/templates/pull-request/pull-request-list.model.go index b290c5f..e18554f 100644 --- a/templates/pull-request/pull-request-list.model.go +++ b/templates/pull-request/pull-request-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositoryPullRequestListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel LoginInfo *LoginInfoModel diff --git a/templates/pull-request/single-pull-request.model.go b/templates/pull-request/single-pull-request.model.go index afc388a..075f325 100644 --- a/templates/pull-request/single-pull-request.model.go +++ b/templates/pull-request/single-pull-request.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositorySinglePullRequestTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel LoginInfo *LoginInfoModel diff --git a/templates/registration.model.go b/templates/registration.model.go index c7c1ef9..10627dd 100644 --- a/templates/registration.model.go +++ b/templates/registration.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type RegistrationTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig ErrorMsg string LoginInfo *LoginInfoModel } diff --git a/templates/renderACLTuple.func.go b/templates/renderACLTuple.func.go index d4e76bf..b90fba5 100644 --- a/templates/renderACLTuple.func.go +++ b/templates/renderACLTuple.func.go @@ -1,7 +1,7 @@ //go:build ignore package templates -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" model.ToCommaSeparatedString diff --git a/templates/repo-setting/change-info.model.go b/templates/repo-setting/change-info.model.go index 48d3565..de24ef7 100644 --- a/templates/repo-setting/change-info.model.go +++ b/templates/repo-setting/change-info.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositorySettingTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel RepoFullName string diff --git a/templates/repo-setting/edit-label.model.go b/templates/repo-setting/edit-label.model.go index d6697eb..7fd10ed 100644 --- a/templates/repo-setting/edit-label.model.go +++ b/templates/repo-setting/edit-label.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositorySettingEditLabelTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel RepoFullName string diff --git a/templates/repo-setting/edit-member.model.go b/templates/repo-setting/edit-member.model.go index 9bfca4d..090605f 100644 --- a/templates/repo-setting/edit-member.model.go +++ b/templates/repo-setting/edit-member.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositorySettingEditMemberTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel RepoFullName string diff --git a/templates/repo-setting/edit-webhook.model.go b/templates/repo-setting/edit-webhook.model.go index a05055d..760059d 100644 --- a/templates/repo-setting/edit-webhook.model.go +++ b/templates/repo-setting/edit-webhook.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositorySettingEditWebHookTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel RepoFullName string diff --git a/templates/repo-setting/hook-list.model.go b/templates/repo-setting/hook-list.model.go index ac1d2b1..55ba01e 100644 --- a/templates/repo-setting/hook-list.model.go +++ b/templates/repo-setting/hook-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositorySettingHookListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel RepoFullName string diff --git a/templates/repo-setting/member-list.model.go b/templates/repo-setting/member-list.model.go index a67d1f0..ed4bb7a 100644 --- a/templates/repo-setting/member-list.model.go +++ b/templates/repo-setting/member-list.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type RepositorySettingMemberListTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo *RepoHeaderTemplateModel RepoFullName string diff --git a/templates/repository.model.go b/templates/repository.model.go index 41bfb71..0b48b8b 100644 --- a/templates/repository.model.go +++ b/templates/repository.model.go @@ -1,11 +1,11 @@ //go:build ignore package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type RepositoryModel struct{ - Config *aegis.AegisConfig + Config *gitus.GitusConfig Repository *model.Repository RepoHeaderInfo RepoHeaderTemplateModel BranchList map[string]*gitlib.Branch diff --git a/templates/retrieveCommentOnCode.func.go b/templates/retrieveCommentOnCode.func.go index ab0be69..ccbc477 100644 --- a/templates/retrieveCommentOnCode.func.go +++ b/templates/retrieveCommentOnCode.func.go @@ -3,11 +3,11 @@ package templates import "encoding/json" import "path" -import "github.com/bctnry/aegis/pkg/gitlib" -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" -func(cfg *aegis.AegisConfig, s string) *model.PullRequestCommentOnCode { +func(cfg *gitus.GitusConfig, s string) *model.PullRequestCommentOnCode { var r *model.PullRequestCommentOnCode json.Unmarshal([]byte(s), &r) p := path.Join(cfg.GitRoot, r.RepoNamespace, r.RepoName) diff --git a/templates/setting/edit-gpg-key.model.go b/templates/setting/edit-gpg-key.model.go index d840000..ac9a67e 100644 --- a/templates/setting/edit-gpg-key.model.go +++ b/templates/setting/edit-gpg-key.model.go @@ -2,14 +2,14 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminUserEditGPGKeyTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel - User *model.AegisUser - Key *model.AegisSigningKey + User *model.GitusUser + Key *model.GitusSigningKey ErrorMsg struct{ Type string Message string diff --git a/templates/setting/edit-ssh-key.model.go b/templates/setting/edit-ssh-key.model.go index d718757..0ab905b 100644 --- a/templates/setting/edit-ssh-key.model.go +++ b/templates/setting/edit-ssh-key.model.go @@ -2,14 +2,14 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type AdminUserEditSSHKeyTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel - User *model.AegisUser - Key *model.AegisAuthKey + User *model.GitusUser + Key *model.GitusAuthKey ErrorMsg struct{ Type string Message string diff --git a/templates/setting/email.model.go b/templates/setting/email.model.go index 3ff2099..f4f17bc 100644 --- a/templates/setting/email.model.go +++ b/templates/setting/email.model.go @@ -2,11 +2,11 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type SettingEmailTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel EmailList []struct{ Email string diff --git a/templates/setting/gpg-key.model.go b/templates/setting/gpg-key.model.go index f7e2917..87bf50f 100644 --- a/templates/setting/gpg-key.model.go +++ b/templates/setting/gpg-key.model.go @@ -2,13 +2,13 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type SettingGPGKeyTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel - KeyList []model.AegisSigningKey + KeyList []model.GitusSigningKey ErrorMsg struct{ Type string Message string diff --git a/templates/setting/privacy.model.go b/templates/setting/privacy.model.go index 8f182de..890460d 100644 --- a/templates/setting/privacy.model.go +++ b/templates/setting/privacy.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type SettingPrivacyTemplateModel struct { - Config *aegis.AegisConfig - User *model.AegisUser + Config *gitus.GitusConfig + User *model.GitusUser LoginInfo *LoginInfoModel ErrorMsg struct{ Type string diff --git a/templates/setting/ssh-key.model.go b/templates/setting/ssh-key.model.go index b241802..2028a55 100644 --- a/templates/setting/ssh-key.model.go +++ b/templates/setting/ssh-key.model.go @@ -2,13 +2,13 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type SettingSSHKeyTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel - KeyList []model.AegisAuthKey + KeyList []model.GitusAuthKey ErrorMsg struct{ Type string Message string diff --git a/templates/setting/user-info.model.go b/templates/setting/user-info.model.go index 975b51f..9665156 100644 --- a/templates/setting/user-info.model.go +++ b/templates/setting/user-info.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" type SettingUserInfoTemplateModel struct { - Config *aegis.AegisConfig - User *model.AegisUser + Config *gitus.GitusConfig + User *model.GitusUser LoginInfo *LoginInfoModel ErrorMsg struct{ Type string diff --git a/templates/shouldShowSynchronizeLink.func.go b/templates/shouldShowSynchronizeLink.func.go index ad0114a..d48e515 100644 --- a/templates/shouldShowSynchronizeLink.func.go +++ b/templates/shouldShowSynchronizeLink.func.go @@ -1,7 +1,7 @@ //go:build ignore package templates -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" func(s *LoginInfoModel, ci *gitlib.BranchComparisonInfo) bool { if !s.LoggedIn { return false } diff --git a/templates/shutdown-notice.model.go b/templates/shutdown-notice.model.go index db69d24..c8d503a 100644 --- a/templates/shutdown-notice.model.go +++ b/templates/shutdown-notice.model.go @@ -2,10 +2,10 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" type ShutdownNoticeTemplateModel struct{ - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel Message string } diff --git a/templates/snippet/all-file.model.go b/templates/snippet/all-file.model.go index c044229..3357610 100644 --- a/templates/snippet/all-file.model.go +++ b/templates/snippet/all-file.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type SnippetAllFileTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel Snippet *model.Snippet DisplayingFileList map[string]string diff --git a/templates/snippet/edit-file.model.go b/templates/snippet/edit-file.model.go index 2e540af..0c214e3 100644 --- a/templates/snippet/edit-file.model.go +++ b/templates/snippet/edit-file.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type SnippetEditFileTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel BelongingUser string Name string diff --git a/templates/snippet/new-file.model.go b/templates/snippet/new-file.model.go index 2ac0900..90bf732 100644 --- a/templates/snippet/new-file.model.go +++ b/templates/snippet/new-file.model.go @@ -2,12 +2,12 @@ package templates -import "github.com/bctnry/aegis/pkg/aegis" -import "github.com/bctnry/aegis/pkg/aegis/model" -import "github.com/bctnry/aegis/pkg/gitlib" +import "github.com/GitusCodeForge/Gitus/pkg/gitus" +import "github.com/GitusCodeForge/Gitus/pkg/gitus/model" +import "github.com/GitusCodeForge/Gitus/pkg/gitlib" type SnippetNewFileTemplateModel struct { - Config *aegis.AegisConfig + Config *gitus.GitusConfig LoginInfo *LoginInfoModel BelongingUser string Name string