Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu008 committed Mar 15, 2024
1 parent 6ee5ac5 commit c9efbe2
Showing 1 changed file with 43 additions and 42 deletions.
85 changes: 43 additions & 42 deletions tests/remove_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,46 @@
from github import Github
import os

uat_file_path = "uat_new_collections.json"
ops_file_path = "ops_new_collections.json"
new_collection_titles = []

with open(uat_file_path, "r") as json_file:
data = json.load(json_file)
for collection in data:
concept_id = collection.get('concept_id')
short_name = collection.get('short_name')
title = f"UAT {concept_id} ({short_name})"
new_collection_titles.append(title)

with open(ops_file_path, "r") as json_file:
data = json.load(json_file)
for collection in data:
concept_id = collection.get('concept_id')
short_name = collection.get('short_name')
title = f"UAT {concept_id} ({short_name})"
new_collection_titles.append(title)

# Replace these variables with your own values
repo_owner = 'podaac'
repo_name = 'l2ss-py-autotest'
github_token = os.getenv("GITHUB_TOKEN")

# Initialize a Github instance
g = Github(github_token)

# Get the repository
repo = g.get_repo(f"{repo_owner}/{repo_name}")

# Get all open pull requests
open_pulls = repo.get_pulls(state='open')

# Print each open pull request title and URL
for pull in open_pulls:
if pull.title not in new_collection_titles:
print(f"Pull Request #{pull.number}: {pull.title} needs to be closed")
print()

# Close the pull request
#pull.edit(state='closed')
if __name__ == "__main__":

uat_file_path = "uat_new_collections.json"
ops_file_path = "ops_new_collections.json"
new_collection_titles = []

with open(uat_file_path, "r") as json_file:
data = json.load(json_file)
for collection in data:
concept_id = collection.get('concept_id')
short_name = collection.get('short_name')
title = f"UAT {concept_id} ({short_name})"
new_collection_titles.append(title)

with open(ops_file_path, "r") as json_file:
data = json.load(json_file)
for collection in data:
concept_id = collection.get('concept_id')
short_name = collection.get('short_name')
title = f"UAT {concept_id} ({short_name})"
new_collection_titles.append(title)

# Replace these variables with your own values
repo_owner = 'podaac'
repo_name = 'l2ss-py-autotest'
github_token = os.getenv("GITHUB_TOKEN")

# Initialize a Github instance
g = Github(github_token)

# Get the repository
repo = g.get_repo(f"{repo_owner}/{repo_name}")

# Get all open pull requests
open_pulls = repo.get_pulls(state='open')

# Print each open pull request title and URL
for pull in open_pulls:
if pull.title not in new_collection_titles:
print(f"Pull Request #{pull.number}: {pull.title} needs to be closed")
print()
# Close the pull request
pull.edit(state='closed')

0 comments on commit c9efbe2

Please sign in to comment.