Skip to content

Delete patched elements, when deleted from srcd #316

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dpordomingo
Copy link
Contributor

@dpordomingo dpordomingo commented Oct 28, 2019

fix #225
blocks #320

When in development it is used make dev-prepare, the content of srcd is copied into sourced and a watcher is coping it again every time one file from srcd is updated.
Now:

  • it listens for deletions, renames, and moves.
  • it now updates the docker-compose.override.yml from ~/.sourced/compose-files/__active__ when srcd/contrib/docker/docker-compose.override.yml changes.

  • I have updated the CHANGELOG file according to the conventions in keepachangelog.com
  • This PR contains changes that do not require a mention in the CHANGELOG file

@dpordomingo dpordomingo added the enhancement New feature or request label Oct 28, 2019
@dpordomingo dpordomingo requested review from smacker, se7entyse7en and a team October 28, 2019 15:49
@dpordomingo dpordomingo self-assigned this Oct 28, 2019
@dpordomingo dpordomingo removed the request for review from a team October 28, 2019 15:54
Copy link
Contributor

@smacker smacker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it handle rename/move correctly?

@dpordomingo
Copy link
Contributor Author

I'll add later some logs of the different events from the different watchers.

@dpordomingo
Copy link
Contributor Author

Either using inotify or fswatch, both rename and move events are handled properly, you can see below how these tests are treated.

$ touch extra.less
$ mkdir component
$ mv extra.less component/
$ mv component/extra.less component/component.less
$ rm component/extra-to-delete.less
$ rm -rf component/
    $ touch extra.less
    # events from inotify:
        srcd/superset/assets/stylesheets/less/ CREATE extra.less
        srcd/superset/assets/stylesheets/less/ MODIFY extra.less
    # events from fswatch:
        srcd/superset/assets/stylesheets/less/extra.less Created
        srcd/superset/assets/stylesheets/less/extra.less Updated
    # actions:
        [modified]: srcd/superset/assets/stylesheets/less/extra.less
        cp -r srcd/* superset/
        [modified]: srcd/superset/assets/stylesheets/less/extra.less
        cp -r srcd/* superset/

    $ mkdir component
    # events from inotify:
        srcd/superset/assets/stylesheets/less/ CREATE,ISDIR component
    # events from fswatch:
        srcd/superset/assets/stylesheets/less/component Created
    # actions:
        [modified]: srcd/superset/assets/stylesheets/less/component
        cp -r srcd/* superset/

    $ mv extra.less component/
    # events from inotify:
        srcd/superset/assets/stylesheets/less/ MOVED_FROM extra.less
        srcd/superset/assets/stylesheets/less/component/ MOVED_TO extra.less
    # events from fswatch:
        srcd/superset/assets/stylesheets/less/extra.less Removed MovedFrom
        srcd/superset/assets/stylesheets/less/component/extra.less Created MovedTo
    # actions:
        [deleted]: srcd/superset/assets/stylesheets/less/extra.less
        rm -rf superset/superset/assets/stylesheets/less/extra.less
        [modified]: srcd/superset/assets/stylesheets/less/component/extra.less
        cp -r srcd/* superset/

    $ mv component/extra.less component/component.less
    # events from inotify:
        srcd/superset/assets/stylesheets/less/component/ MOVED_FROM extra.less
        srcd/superset/assets/stylesheets/less/component/ MOVED_TO component.less
    # events from fswatch:
        srcd/superset/assets/stylesheets/less/component/extra.less Removed MovedFrom
        srcd/superset/assets/stylesheets/less/component/component.less Created MovedTo
    # actions:
        [deleted]: srcd/superset/assets/stylesheets/less/component/extra.less
        rm -rf superset/superset/assets/stylesheets/less/component/extra.less
        [modified]: srcd/superset/assets/stylesheets/less/component/component.less
        cp -r srcd/* superset/

    $ rm component/extra-to-delete.less
    # events from inotify:
        srcd/superset/assets/stylesheets/less/component/ DELETE extra-to-delete.less
    # events from fswatch:
        srcd/superset/assets/stylesheets/less/component/extra-to-delete.less Removed
    # actions:
        [deleted]: srcd/superset/assets/stylesheets/less/component/extra-to-delete.less
        rm -rf superset/superset/assets/stylesheets/less/component/extra-to-delete.less

    $ rm -rf component/
    # events from inotify:
        srcd/superset/assets/stylesheets/less/component/ DELETE component.less
        srcd/superset/assets/stylesheets/less/ DELETE,ISDIR component
    # events from fswatch:
        srcd/superset/assets/stylesheets/less/component/component.less Removed
        srcd/superset/assets/stylesheets/less/component Removed
    # actions:
        [deleted]: srcd/superset/assets/stylesheets/less/component/component.less
        rm -rf superset/superset/assets/stylesheets/less/component/component.less
        [deleted]: srcd/superset/assets/stylesheets/less/component
        rm -rf superset/superset/assets/stylesheets/less/component

Handle create, modify, move, rename and delete events.

Signed-off-by: David Pordomingo <[email protected]>
It copies the modified 'docker-compose.override.yml' into
'~/.sourced/compose-files/__active__/docker-compose.override.yml'

Signed-off-by: David Pordomingo <[email protected]>
@dpordomingo dpordomingo mentioned this pull request Nov 7, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete files on delete watcher event
2 participants