Only send commit requests when needed
This commit is contained in:
parent
d3e2547ee6
commit
45a03db02f
1 changed files with 14 additions and 8 deletions
22
archiver.py
22
archiver.py
|
@ -3,19 +3,25 @@ import os
|
|||
|
||||
ARCHIVE_ORG = "archive"
|
||||
|
||||
def set_if_needed(item, attr, value):
|
||||
if getattr(item, attr) != value:
|
||||
setattr(item, attr, value)
|
||||
|
||||
def main():
|
||||
gitea = Gitea(os.environ["GITEA_URL"], os.environ["GITEA_TOKEN"])
|
||||
|
||||
org = Organization.request(gitea, ARCHIVE_ORG)
|
||||
|
||||
print("Fetching repositories...")
|
||||
for repo in org.get_repositories():
|
||||
print(repo.get_full_name())
|
||||
repo.archived = True
|
||||
repo.has_projects = False
|
||||
repo.has_issues = False
|
||||
repo.has_pull_requests = False
|
||||
repo.has_wiki = False
|
||||
repo.commit()
|
||||
set_if_needed(repo, "archived", True)
|
||||
set_if_needed(repo, "has_projects", False)
|
||||
set_if_needed(repo, "has_issues", False)
|
||||
set_if_needed(repo, "has_pull_requests", False)
|
||||
set_if_needed(repo, "has_wiki", False)
|
||||
|
||||
if repo.get_dirty_fields():
|
||||
print("Updating", repo.get_full_name())
|
||||
repo.commit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue