atomist-attic / rug-resolver

Resolver library used to resolve Rug Operations and Archives
GNU General Public License v3.0
1 stars 1 forks source link

project.name() should return a name not a directory #11

Closed kipz closed 7 years ago

kipz commented 7 years ago

From @Lawouach on October 28, 2016 14:26

It's confusing, and not practical, that the name() function on the project object returns a directory when used locally.

We should instead have something like: project.location() when we want the location (directory path or URL) of the project and be consistent with project.name() returning the name of the project (as one might expect).

This is actually an issue for me with:

I would like this:

@description "Only work on projects that run a Flask application"
predicate IsFlaskProject
  with project p
    when { p.fileContains(p.location() + "/" + p.name() + "/__init__.py", "app = Flask(__name__)") }

I think that whole comes back to the fact we use the project_name for many things at once. GH repo name, slack channel name...

I consider this a bug but feel free to re-qualify.

Copied from original issue: atomist-recycling/rug-lib#58

kipz commented 7 years ago

From @Lawouach on October 31, 2016 15:52

Here is the ugly workaround I'm using for now:

https://github.com/atomist-project-templates/flask-service/blob/master/.atomist/editors/AddDockerfile.rug#L37

with project p
    with file f when f.name = "Dockerfile"
        do replace "flask_service" {
                                        var name = p.name();
                                        var segments = name.split('/');
                                        if (name.startsWith('/'))
                                           name = segments.reverse()[0];
                                        else if (segments.length > 1)
                                           name = segments[1];
                                        else
                                           name = segments[0];
                                        return(name);
                                    }

The first case is for when editing locally as p.name() returns a directory. The second case is when running the tests and the last case is when actually running against GitHub.

In all three cases, p.name() returns a different form.

kipz commented 7 years ago

From @Lawouach on November 3, 2016 18:32

I realise now there is two distinct questions here:

1) ProjectMutableView.name doesn't actually refer to the name of the project but its location. So maybe, it's just a case of renaming it to location() or create an alias so that it's less misleading.

2) The real issue here is that I want my editors to have access to the parameters that were used to generate the project. But that's not that easy:

a) An editor can be applied against a project that was not generated through Atomist. In that case, you don't have any parameters to load anyway b) Even if the project was generated via atomist, the initial parameters may not match the reality anymore (the user may have changed the project name directly in the code for instance). I had initially thought we could load parameters from th .provenance.txt file.

So, maybe, for editors, we are indeed "doomed" to ask for the same parameters when we do need them and when those editors aren't applied from a generator but stand alone.

Thoughts @russmiles, @johnsonr, @alankstewart?

cdupuis commented 7 years ago

@kipz, why did that that end up in rug-resolver and not in rug?

kipz commented 7 years ago

This issue was moved to atomist/rug#101