Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions pot_github_push/wizard/pot_generator_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import contextlib
import io
import logging
import time

import requests
from odoo import api, models
Expand Down Expand Up @@ -112,17 +113,25 @@ def _github_push(self, module_name, content, repo_owner, repo_name, github_token
if sha:
commit_data["sha"] = sha

# Push to GitHub
response = requests.put(url, json=commit_data, headers=headers, timeout=30)
# Push to GitHub. A 409 means GitHub still sees the branch as it was
# before a push made a moment ago, so wait and try again.
for attempt in range(3):
if attempt:
time.sleep(2)
response = requests.put(url, json=commit_data, headers=headers, timeout=30)
if response.status_code != 409:
break
if response.status_code in [200, 201]:
_logger.info("GitHub push completed for %s", module_name)
return True
else:
_logger.error("GitHub push failed for %s: %s", module_name, response.text)
_logger.error(
"GitHub push failed for %s (HTTP %s): %s", module_name, response.status_code, response.text
)
return False

except Exception as e:
_logger.error("GitHub push failed for %s: %s", module_name, str(e))
_logger.error("GitHub push failed for %s: %r", module_name, e)
return False
finally:
# Clear headers to avoid keeping sensitive token data in memory
Expand Down
Loading