Skip to content

delete test gist that is created by --check-github#3031

Merged
migueldiascosta merged 1 commit intoeasybuilders:developfrom
boegel:delete_gist
Sep 24, 2019
Merged

delete test gist that is created by --check-github#3031
migueldiascosta merged 1 commit intoeasybuilders:developfrom
boegel:delete_gist

Conversation

@boegel
Copy link
Copy Markdown
Member

@boegel boegel commented Sep 23, 2019

--check-github creates a test gist, but doesn't clean it up afterwards, fixed here...

@boegel boegel added the bug fix label Sep 23, 2019
@boegel boegel added this to the next release (4.0.1) milestone Sep 23, 2019
@boegel
Copy link
Copy Markdown
Member Author

boegel commented Sep 23, 2019

I had a whole bunch of these test gists, here's a script to clean them up if you have too...

from easybuild.base.rest import RestClient
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.github import GITHUB_API_URL, HTTP_STATUS_OK, fetch_github_token

HTTP_DELETE_OK = 204

username = 'boegel'
token = fetch_github_token(username)

gh = RestClient(GITHUB_API_URL, username=username, token=token)

gists_to_delete = []
cur_page = 1
while True:
    status, gists = gh.gists.get(per_page=100, page=cur_page)
    print("Collecting gists (page %d), found %d gists to delete" % (cur_page, len(gists_to_delete)))
    if gists:
        cur_page += 1
        for gist in gists:
            if gist['description'] == 'test123' and gist['files'].keys() == ['test.txt']:
                gists_to_delete.append(gist)
    else:
        break

cnt = len(gists_to_delete)
print("Deleting %d gists..." % cnt)
for idx, gist in enumerate(gists_to_delete):
    gh.gists[gist["id"]].delete()
    print("Deleted %d/%s" % (idx, cnt))

Copy link
Copy Markdown
Member

@migueldiascosta migueldiascosta left a comment

Choose a reason for hiding this comment

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

lgtm, and works as advertised

@migueldiascosta
Copy link
Copy Markdown
Member

Going in, thanks @boegel!

@migueldiascosta migueldiascosta merged commit 787fa29 into easybuilders:develop Sep 24, 2019
@boegel boegel deleted the delete_gist branch September 24, 2019 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants