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:
parent
bcbc3420a1
commit
dde4c97802
|
@ -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) {
|
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 {
|
if err != nil {
|
||||||
fmt.Println("Error deleting project:", err)
|
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 {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
{{- range . -}}
|
{{- range . -}}
|
||||||
{{- if ne .Running (index .Releases 0).Tag -}}
|
{{- if ne .Running (index .Releases 0).Tag -}}
|
||||||
<div id="{{ .ID }}" class="project card">
|
<div id="{{ .ID }}" class="project card">
|
||||||
<h3><a href="{{ .URL }}">{{ .Name }}</a> <span class="delete"><a href="/new?action=delete&url={{ .URL }}">Delete?</a></span></h3>
|
<h3><a href="{{ .URL }}">{{ .Name }}</a> <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>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>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>
|
<p><a href="#{{ (index .Releases 0).ID }}">View release notes</a></p>
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
{{- range . -}}
|
{{- range . -}}
|
||||||
{{- if eq .Running (index .Releases 0).Tag -}}
|
{{- if eq .Running (index .Releases 0).Tag -}}
|
||||||
<div class="project card">
|
<div class="project card">
|
||||||
<h3><a href="{{ .URL }}">{{ .Name }}</a> <span class="delete"><a href="/new?action=delete&url={{ .URL }}">Delete?</a></span></h3>
|
<h3><a href="{{ .URL }}">{{ .Name }}</a> <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>
|
<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>
|
</div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
Loading…
Reference in New Issue