New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
charmcraft/jujuignore.py: Allow extending the list of patterns. #99
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Some small easy changes, thanks!
charmcraft/commands/build.py
Outdated
ignore.extend_patterns(ignores) | ||
return ignore | ||
|
||
def _walk_unignored(self, topdir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this.
Anyway, I need to implement the "walk" outside, as it will be ignoring different stuff (a part of which is jujuignored).
So I think this shouldn't be included in this layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
def handle_code(self): | ||
"""Handle basic files and the charm source code.""" | ||
# basic files | ||
logger.debug("Linking in basic files and charm code") | ||
self._link_to_buildpath(self.charmdir / CHARM_METADATA) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reduce this to only one blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
charmcraft/jujuignore.py
Outdated
def _compile_from(self, patterns): | ||
def extend_patterns(self, patterns: typing.Iterable[str]) -> None: | ||
"""Add more patterns to the ignore list. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please close the docstring in the same line above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
charmcraft/commands/build.py
Outdated
@@ -26,6 +26,7 @@ | |||
|
|||
from charmcraft.cmdbase import BaseCommand, CommandError | |||
from .utils import make_executable | |||
from .jujuignore import JujuIgnore, default_juju_ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect flake8 will fail on these...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it was supposed to be "..jujuignore" since it is in the parent directory, but flake8 doesn't complain at that point.
charmcraft/commands/build.py
Outdated
ignore = JujuIgnore(default_juju_ignore) | ||
path = self.charmdir / '.jujuignore' | ||
if path.exists(): | ||
with path.open() as ignores: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we specify the encoding here? Which is the expected encoding for the .jujuignore
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.gitignore is officially UTF-8, I don't know that Juju specifically declares an encoding, but there isn't any reason to believe it anything but UTF-8.
@@ -109,11 +111,20 @@ def _link_to_buildpath(self, srcpath): | |||
destpath.symlink_to(srcpath) | |||
return destpath | |||
|
|||
def _load_juju_ignore(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function needs tests.
@@ -151,7 +151,11 @@ def __init__(self, patterns: typing.Iterable[str]): | |||
self._matchers = [] | |||
self._compile_from(patterns) | |||
|
|||
def _compile_from(self, patterns): | |||
def extend_patterns(self, patterns: typing.Iterable[str]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll use this also from tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!!
charmcraft/commands/build.py
Outdated
@@ -26,6 +26,7 @@ | |||
|
|||
from charmcraft.cmdbase import BaseCommand, CommandError | |||
from .utils import make_executable | |||
from ..jujuignore import JujuIgnore, default_juju_ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not from charmcraft.jujuignore
as we do for the rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird. I like from . import foo
and from .foo import bar
and even from .. import foo
, but not from ..foo import bar
.
I'm happy either way.
…On Wed, Aug 12, 2020, 18:31 Facundo Batista ***@***.***> wrote:
***@***.**** approved this pull request.
Great, thanks!!
------------------------------
In charmcraft/commands/build.py
<#99 (comment)>:
> @@ -26,6 +26,7 @@
from charmcraft.cmdbase import BaseCommand, CommandError
from .utils import make_executable
+from ..jujuignore import JujuIgnore, default_juju_ignore
Why not from charmcraft.jujuignore as we do for the rest?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#99 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABRQ7J3UVKAHJEV3CGTOMLSAKRV5ANCNFSM4PLQ3GXQ>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve.
charmcraft/commands/build.py
Outdated
@@ -26,6 +26,7 @@ | |||
|
|||
from charmcraft.cmdbase import BaseCommand, CommandError | |||
from .utils import make_executable | |||
from ..jujuignore import JujuIgnore, default_juju_ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird. I like from . import foo
and from .foo import bar
and even from .. import foo
, but not from ..foo import bar
.
Cleanup a bunch of small issues found in review. (whitespace, bad imports, etc.)
Add tests for _load_jujuignore and its behavior around default ignores and extending those ignores with the content of .jujuignore, as well as clarify the encoding of the file.
55cb3b0
to
e803844
Compare
This adds the ability for JujuIgnore to pull in the default ignores and extend them with .jujuignore contents.
I don't have tests around the walk functionality, but I figured I would leave it in there to show you how I was thinking it would look.