Improve logic around untracking projects

Frontend was still passing the project's URL to the backend even though
the backend had been refactored to use the project's ID. This is fixed.

Deleting the repo's files should also work now, but I do think I want to
support tracking multiple instances of the same project. This means
we'll need to check for other instances relying on the repo before
deleting it.

We need end-to-end tests 😩😩😩
This commit is contained in:
Amolith 2024-02-29 15:02:15 -05:00
parent bcbc3420a1
commit dde4c97802
Signed by: Amolith
SSH Key Fingerprint: SHA256:JBKEeoO/72Fz03rtlzeO49PATFT2maMancH3opcT0h0
2 changed files with 11 additions and 4 deletions

View File

@ -172,12 +172,19 @@ func Track(dbConn *sql.DB, mu *sync.Mutex, manualRefresh *chan struct{}, name, u
}
func Untrack(dbConn *sql.DB, mu *sync.Mutex, id string) {
err := db.DeleteProject(dbConn, mu, id)
proj, err := db.GetProject(dbConn, id)
if err != nil {
fmt.Println("Error getting project:", err)
}
err = db.DeleteProject(dbConn, mu, proj["id"])
if err != nil {
fmt.Println("Error deleting project:", err)
}
err = git.RemoveRepo(id)
// TODO: before removing, check whether other tracked projects use the same
// repo
err = git.RemoveRepo(proj["url"])
if err != nil {
log.Println(err)
}

View File

@ -34,7 +34,7 @@
{{- range . -}}
{{- if ne .Running (index .Releases 0).Tag -}}
<div id="{{ .ID }}" class="project card">
<h3><a href="{{ .URL }}">{{ .Name }}</a>&nbsp;&nbsp;&nbsp;<span class="delete"><a href="/new?action=delete&url={{ .URL }}">Delete?</a></span></h3>
<h3><a href="{{ .URL }}">{{ .Name }}</a>&nbsp;&nbsp;&nbsp;<span class="delete"><a href="/new?action=delete&id={{ .ID }}">Delete?</a></span></h3>
<p>You've selected {{ .Running }}. <a href="/new?action=update&url={{ .URL }}&forge={{ .Forge }}&name={{ .Name }}">Modify?</a></p>
<p>Latest: <a href="{{ (index .Releases 0).URL }}">{{ (index .Releases 0).Tag }}</a></p>
<p><a href="#{{ (index .Releases 0).ID }}">View release notes</a></p>
@ -52,7 +52,7 @@
{{- range . -}}
{{- if eq .Running (index .Releases 0).Tag -}}
<div class="project card">
<h3><a href="{{ .URL }}">{{ .Name }}</a>&nbsp;&nbsp;&nbsp;<span class="delete"><a href="/new?action=delete&url={{ .URL }}">Delete?</a></span></h3>
<h3><a href="{{ .URL }}">{{ .Name }}</a>&nbsp;&nbsp;&nbsp;<span class="delete"><a href="/new?action=delete&id={{ .ID }}">Delete?</a></span></h3>
<p>You've selected <a href="#{{ (index .Releases 0).ID }}">{{ .Running }}</a>. <a href="/new?action=update&url={{ .URL }}&forge={{ .Forge }}&name={{ .Name }}">Modify?</a></p>
</div>
{{- end -}}