fix(import): stop a shadowed error from hiding failed repository setup
3 files changed, +2 −14
- forge/feature_test.go modified +0 −1
- forge/import.go modified +2 −8
- forge/moderation.go modified +0 −5
forge/feature_test.go modified
| @@ -201,7 +201,6 @@ func TestReservedNames(t *testing.T) { | ||
| 201 | 201 | type pushRig struct { |
| 202 | 202 | t *testing.T |
| 203 | 203 | s *Server |
| 204 | - url string | |
| 205 | 204 | work string |
| 206 | 205 | } |
| 207 | 206 | |
forge/import.go modified
| @@ -190,16 +190,10 @@ func (s *Server) importRepo(w http.ResponseWriter, r *http.Request) { | ||
| 190 | 190 | return |
| 191 | 191 | } |
| 192 | 192 | dir := s.repoDir(repo) |
| 193 | - if err := os.MkdirAll(path.Dir(dir), 0o755); err == nil { | |
| 194 | - err = initRepo(dir) | |
| 195 | - } | |
| 196 | - if err != nil { | |
| 197 | - os.RemoveAll(dir) | |
| 198 | - s.store.DeleteRepo(repo.ID) | |
| 199 | - fail("Could not create the repository") | |
| 193 | + if err := s.materialise(repo, initRepo); err != nil { | |
| 194 | + fail(err.Error()) | |
| 200 | 195 | return |
| 201 | 196 | } |
| 202 | - installHook(s.root, s.host, dir) | |
| 203 | 197 | s.uploads.fail("import:" + u.Name) |
| 204 | 198 | if r.FormValue("mirror") == "on" { |
| 205 | 199 | box, err := seal(s.root, strings.TrimSpace(r.FormValue("token"))) |
forge/moderation.go modified
| @@ -4,7 +4,6 @@ import ( | ||
| 4 | 4 | "errors" |
| 5 | 5 | "fmt" |
| 6 | 6 | "net/http" |
| 7 | - "net/url" | |
| 8 | 7 | "os" |
| 9 | 8 | "strconv" |
| 10 | 9 | "strings" |
| @@ -392,7 +391,3 @@ func (s *Server) reportAuthor(rep Report) string { | ||
| 392 | 391 | } |
| 393 | 392 | return "" |
| 394 | 393 | } |
| 395 | - | |
| 396 | -func reportURL(kind, target string) string { | |
| 397 | - return "/report?kind=" + kind + "&target=" + url.QueryEscape(target) | |
| 398 | -} | |