moban icon indicating copy to clipboard operation
moban copied to clipboard

Automatic use of local version when `requires: ..` is used

Open jayvdb opened this issue 6 years ago • 2 comments

With a mobanfile containing

requires:
  - https://github.com/django-mobans/docker-mobans

- configuration:
    configuration: .moban.yaml
    template_dir:
      - 'docker-mobans:.moban.dt/'

If I want to test an un-merged change to docker-mobans, I need to edit the mobanfile to look for a local version

- configuration:
    configuration: .moban.yaml
    template_dir:
      - ../docker-mobans/.moban.dt/

It would be nice to have a way to do that change without editing the mobanfile.

The way that would be most suitable for the way we have been setting up repos recently is to convert

'docker-mobans:.moban.dt/' -> ../docker-mobans/.moban.dt/

however iirc pyexcel often has the local version as submodules so that would mean

'docker-mobans:.moban.dt/' -> ./docker-mobans/.moban.dt/

This use of a local version could be triggered with a cli flag like --local-requires

Ideally any modified target includes a header comment describing the different source which was used, but moban doesnt know how to do comments in every language, so that needs to be a separate enhancement, and there are a few quite-old issues which relate to this.

jayvdb avatar Jan 17 '19 07:01 jayvdb

One way to achieve this is to allow some template_dir: to be optional, and/or the same requires to have multiple resolutions

requires:
  - https://github.com/django-mobans/docker-mobans
  - docker-mobans-pkg

configuration:
  template_dir:
    - ../docker-mobans/templates
    - docker-mobans:/templates
    - docker-mobans-pkg:/templates
requires:
  docker-mobans:
    - ../docker-mobans
    - https://github.com/django-mobans/docker-mobans
    - docker-mobans-pkg

The former is more powerful, and keeps the fallback resolution to be only occurring within template_dir.

And the solution could be as simple as allowing any template_dir beginning with ../ to be missing, emit a warning maybe, as an error will occur if the template isnt found in a subsequent template_dir.

However, if using template_dir to include alternatives, that creates a problem for layered template names as hoped in https://github.com/moremoban/moban/issues/17 .

jayvdb avatar Feb 15 '19 01:02 jayvdb

Please try the following configuration as you have proposed. With version 0.6.0, it should work automatically, given that ../docker-mobans/templates exists. Jinja2-FSLoader(MultiFS) should stop at ../docer-mobans/templates/ if the file is found.

configuration:
  template_dir:
    - ../docker-mobans/templates
    - docker-mobans:/templates
    - docker-mobans-pkg:/templates

chfw avatar Sep 09 '19 17:09 chfw