1
Fork 0

Only send commit requests when needed

This commit is contained in:
Jake Howard 2023-03-26 18:22:32 +01:00
parent d3e2547ee6
commit 45a03db02f
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -3,19 +3,25 @@ import os
ARCHIVE_ORG = "archive" ARCHIVE_ORG = "archive"
def set_if_needed(item, attr, value):
if getattr(item, attr) != value:
setattr(item, attr, value)
def main(): def main():
gitea = Gitea(os.environ["GITEA_URL"], os.environ["GITEA_TOKEN"]) gitea = Gitea(os.environ["GITEA_URL"], os.environ["GITEA_TOKEN"])
org = Organization.request(gitea, ARCHIVE_ORG) org = Organization.request(gitea, ARCHIVE_ORG)
print("Fetching repositories...")
for repo in org.get_repositories(): for repo in org.get_repositories():
print(repo.get_full_name()) set_if_needed(repo, "archived", True)
repo.archived = True set_if_needed(repo, "has_projects", False)
repo.has_projects = False set_if_needed(repo, "has_issues", False)
repo.has_issues = False set_if_needed(repo, "has_pull_requests", False)
repo.has_pull_requests = False set_if_needed(repo, "has_wiki", False)
repo.has_wiki = False
repo.commit() if repo.get_dirty_fields():
print("Updating", repo.get_full_name())
repo.commit()
if __name__ == "__main__": if __name__ == "__main__":