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

Add flag to remove the file. #98

Open
ClashTheBunny opened this issue Jul 30, 2021 · 3 comments
Open

Add flag to remove the file. #98

ClashTheBunny opened this issue Jul 30, 2021 · 3 comments

Comments

@ClashTheBunny
Copy link

ClashTheBunny commented Jul 30, 2021

I'd like an option to remove a file. If I have this in CI/CD, I'll end up with all of the deleted files just stagnating. Would you be able to add an option like -d/--delete which reads the header and removes the article at that place?

I'd like to do something like this:

$ git diff 931d9f~1..931d9f7 --name-only --diff-filter=D
test/alice.md
test/bob.md

and then loop over those deleted files and remove them from confluence:

for file in $(git diff 931d9f~1..931d9f7 --name-only --diff-filter=D); do
  mark --delete -f $file
done

(Obviously accounting for spaces and such, it will look more complicated)

@AbianG
Copy link

AbianG commented Nov 11, 2021

Hello, is there an ETA or plan to resolve this issue? I believe is important as it leaves sanitizing the Confluence space as a manual labor in case you want to move pages around.

@markszabo
Copy link

markszabo commented Nov 11, 2021

We came up with this workaround: tag the pages manually that need to be deleted, then run this script. This calls the API to list the tagged pages (also filter for pages created by the bot account), and then calls the API again to delete the pages:

#!/bin/bash
set -euo pipefail

pages=$(curl -u "$CONFLUENCE_USERNAME:$CONFLUENCE_PASSWORD" -X GET "${CONFLUENCE_URL}rest/api/search?cql=contributor='${CONFLUENCE_USERNAME}'+and+label='delete_pls'")
echo "${pages}"
for row in $(echo "${pages}" | tr '\r\n' ' ' | jq -r '.results[] | @base64'); do
    _jq() {
    echo "${row}" | base64 --decode | jq -r "${1}"
    }
    echo "Deleting page: $(_jq '.title') from $(_jq '.url')"
    curl -S --fail -u "$CONFLUENCE_USERNAME:$CONFLUENCE_PASSWORD" -X DELETE "${CONFLUENCE_URL}rest/api/content/$(_jq '.content.id')"
done

@kovetskiy
Copy link
Owner

kovetskiy commented Nov 13, 2021

Hello, is there an ETA or plan to resolve this issue? I believe is important as it leaves sanitizing the Confluence space as a manual labor in case you want to move pages around.

I'm not providing any ETA for any features, if it's an important feature and you'd like to see it as part of mark, you can create a pull request with a feature implementation. I'll be glad to merge it and release a new version with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants