Skip to content
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

archive - fixing determination of archive root when root is '/' #3036

Merged

Conversation

Ajpantuso
Copy link
Collaborator

SUMMARY

Fixes an existing bug in archive that sets the archive root to '///' when the longest common root amongst all paths in path is '/'

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

plugins/modules/files/archive.py

ADDITIONAL INFORMATION
  • Uses standard lib and inline functions where possible for clarity
  • Also makes root calculation a "query" as it's a derived value from paths
  • Replaced regex substitution with built-in methods to reduce repetition and marginally improve performance
  • Added units instead of integration tests.

@ansibullbot
Copy link
Collaborator

cc @bendoh
click here for bot help

@ansibullbot ansibullbot added WIP Work in progress affects_2.10 bug This issue/PR relates to a bug files module module needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_maintainer needs_triage new_plugin New plugin performance plugins plugin (any type) stale_ci CI is older than 7 days, rerun before merging tests tests unit tests/unit labels Jul 19, 2021
@Ajpantuso
Copy link
Collaborator Author

/rebuild_failed

@Ajpantuso Ajpantuso marked this pull request as ready for review July 19, 2021 23:23
@Ajpantuso Ajpantuso changed the title [WIP] archive - fixing determination of archive root when root is '/' archive - fixing determination of archive root when root is '/' Jul 19, 2021
@ansibullbot ansibullbot added community_review and removed WIP Work in progress labels Jul 19, 2021
@felixfontein felixfontein added backport-2 check-before-release PR will be looked at again shortly before release and merged if possible. labels Jul 20, 2021
changelogs/fragments/3036-archive-root-path-fix.yml Outdated Show resolved Hide resolved
plugins/modules/files/archive.py Outdated Show resolved Hide resolved
tests/unit/plugins/modules/files/test_archive.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Looks good, thanks a lot!

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jul 24, 2021
@felixfontein felixfontein merged commit 31189e9 into ansible-collections:main Jul 24, 2021
@patchback
Copy link

patchback bot commented Jul 24, 2021

Backport to stable-2: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 31189e9 on top of patchback/backports/stable-2/31189e96458f199d1cd0a1c384057a2a85a5ff8d/pr-3036

Backporting merged PR #3036 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible-collections/community.general.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/stable-2/31189e96458f199d1cd0a1c384057a2a85a5ff8d/pr-3036 upstream/stable-2
  4. Now, cherry-pick PR archive - fixing determination of archive root when root is '/' #3036 contents into that branch:
    $ git cherry-pick -x 31189e96458f199d1cd0a1c384057a2a85a5ff8d
    If it'll yell at you with something like fatal: Commit 31189e96458f199d1cd0a1c384057a2a85a5ff8d is a merge but no -m option was given., add -m 1 as follows intead:
    $ git cherry-pick -m1 -x 31189e96458f199d1cd0a1c384057a2a85a5ff8d
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR archive - fixing determination of archive root when root is '/' #3036 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/stable-2/31189e96458f199d1cd0a1c384057a2a85a5ff8d/pr-3036
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link

patchback bot commented Jul 24, 2021

Backport to stable-3: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-3/31189e96458f199d1cd0a1c384057a2a85a5ff8d/pr-3036

Backported as #3062

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein
Copy link
Collaborator

@Ajpantuso thanks a lot for fixing this!

patchback bot pushed a commit that referenced this pull request Jul 24, 2021
* Initial commit

* Fixing units and path joins

* Ensuring paths are consistently ordered

* Adding changelog fragment

* Using os.path.join to ensure trailing slashes are present

* optimizing use of root in add_targets

* Applying initial review suggestions

(cherry picked from commit 31189e9)
felixfontein pushed a commit that referenced this pull request Jul 24, 2021
… (#3062)

* Initial commit

* Fixing units and path joins

* Ensuring paths are consistently ordered

* Adding changelog fragment

* Using os.path.join to ensure trailing slashes are present

* optimizing use of root in add_targets

* Applying initial review suggestions

(cherry picked from commit 31189e9)

Co-authored-by: Ajpantuso <[email protected]>
Ajpantuso added a commit to Ajpantuso/community.general that referenced this pull request Jul 24, 2021
…ble-collections#3036)

* Initial commit

* Fixing units and path joins

* Ensuring paths are consistently ordered

* Adding changelog fragment

* Using os.path.join to ensure trailing slashes are present

* optimizing use of root in add_targets

* Applying initial review suggestions

(cherry picked from commit 31189e9)
@Ajpantuso
Copy link
Collaborator Author

Opened #3065 for manually backporting to stable-2.

@Ajpantuso Ajpantuso deleted the archive_root_path_fix branch July 24, 2021 21:30
felixfontein pushed a commit that referenced this pull request Jul 25, 2021
… of archive root when root is '/' (#3065)

* archive - fixing determination of archive root when root is '/' (#3036)

* Initial commit

* Fixing units and path joins

* Ensuring paths are consistently ordered

* Adding changelog fragment

* Using os.path.join to ensure trailing slashes are present

* optimizing use of root in add_targets

* Applying initial review suggestions

(cherry picked from commit 31189e9)

* removing unneccessary addition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug community_review files module module needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_maintainer new_plugin New plugin performance plugins plugin (any type) stale_ci CI is older than 7 days, rerun before merging tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants