Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial LLM-powered code generation script #4537

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
16 changes: 16 additions & 0 deletions bugbug/phabricator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datetime import datetime, timedelta
from typing import Collection, Iterator, NewType

import requests
import tenacity
from libmozdata.phabricator import PhabricatorAPI
from tqdm import tqdm
Expand Down Expand Up @@ -291,3 +292,18 @@ def get_pending_review_time(rev: RevisionDict) -> timedelta | None:
return datetime.utcnow() - last_exclusion_end_date
else:
return datetime.utcnow() - creation_date


def fetch_diff_from_url(
revision_id, first_patch, second_patch=None, single_patch=False
):
if single_patch:
url = f"https://phabricator.services.mozilla.com/D{revision_id}?id={first_patch}&download=true"
else:
url = f"https://phabricator.services.mozilla.com/D{revision_id}?vs={first_patch}&id={second_patch}&download=true"

response = requests.get(url)
if response.status_code == 200:
return response.text
else:
raise Exception(f"Failed to download diff from URL: {url}")
Loading