Fix issue preventing `include`ed sources from being mapped to the repo root by solidDoWant · Pull Request #1659 · fluxcd/source-controller

This PR fixes #1657. With this change, it should be possible to configure a GitRepository like so:

apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: example
spec:
  # Omitting boilerplate for brevity
  include:
    - repository:
        name: some-other-repo
      fromPath: /some/other/repos/path
      toPath: /  # This line does not work without this patch

This approach is nice because Kustomizations using the example GitRepository can now set the path field to /some/subdirectory instead of /some/other/repos/path/some/subdirectory, making it easier to read. I've deployed this change and an example of its usage here. An image is available to test this here.