dmitri.shuralyov.com/website/gido

add to openChanges and closedChanges when len(paths) == 0 && root != ""

Changes that have an import path that doesn't correspond to any
existing directory, but do have a non-empty root, are considered
to belong to the root directory. Add them, so they show up as
expected when doing an import path pattern query that matches
a repository root.

This edge-case was originally unintentionally overlooked.

Fixes https://dmitri.shuralyov.com/website/gido/...$issues/5.
dmitshur committed 5 years ago commit b36d6d3cb7ee809e6244a5f67a571a2d70f46b4a
Showing partial commit. Full Commit
Collapse all
service.go
@@ -341,10 +341,19 @@ func issuesAndChanges(repo *maintner.GitHubRepo, gerrit *maintner.Gerrit) (
				case change.OpenState:
					openChanges = append(openChanges, ChangeAndPaths{c, paths})
				case change.ClosedState, change.MergedState:
					closedChanges = append(closedChanges, ChangeAndPaths{c, paths})
				}
			} else if root != "" {
				// Consider this change that didn't match any existing directories
				// to belong to the repository root.
				switch c.State {
				case change.OpenState:
					openChanges = append(openChanges, ChangeAndPaths{c, []string{root}})
				case change.ClosedState, change.MergedState:
					closedChanges = append(closedChanges, ChangeAndPaths{c, []string{root}})
				}
			}

			return nil
		})
		return err