mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 21:30:40 +08:00
refactor
This commit is contained in:
@ -36,28 +36,7 @@ async def run_action():
|
|||||||
if not GITHUB_TOKEN:
|
if not GITHUB_TOKEN:
|
||||||
print("GITHUB_TOKEN not set")
|
print("GITHUB_TOKEN not set")
|
||||||
return
|
return
|
||||||
if CUSTOM_LABELS:
|
CUSTOM_LABELS_DICT = handle_custom_labels(CUSTOM_LABELS, CUSTOM_LABELS_DESCRIPTION)
|
||||||
CUSTOM_LABELS = [x.strip() for x in CUSTOM_LABELS.split(',')]
|
|
||||||
else:
|
|
||||||
# Set default labels
|
|
||||||
CUSTOM_LABELS = ['Bug fix', 'Tests', 'Bug fix with tests', 'Refactoring', 'Enhancement', 'Documentation', 'Other']
|
|
||||||
print(f"Using default labels: {CUSTOM_LABELS}")
|
|
||||||
if CUSTOM_LABELS_DESCRIPTION:
|
|
||||||
CUSTOM_LABELS_DESCRIPTION = [x.strip() for x in CUSTOM_LABELS_DESCRIPTION.split(',')]
|
|
||||||
else:
|
|
||||||
# Set default labels
|
|
||||||
CUSTOM_LABELS_DESCRIPTION = ['Fixes a bug in the code', 'Adds or modifies tests',
|
|
||||||
'Fixes a bug in the code and adds or modifies tests',
|
|
||||||
'Refactors the code without changing its functionality',
|
|
||||||
'Adds new features or functionality',
|
|
||||||
'Adds or modifies documentation',
|
|
||||||
'Other changes that do not fit in any of the above categories']
|
|
||||||
print(f"Using default labels: {CUSTOM_LABELS_DESCRIPTION}")
|
|
||||||
|
|
||||||
# create a dictionary of labels and descriptions
|
|
||||||
CUSTOM_LABELS_DICT = dict()
|
|
||||||
for i in range(len(CUSTOM_LABELS)):
|
|
||||||
CUSTOM_LABELS_DICT[CUSTOM_LABELS[i]] = {'description': CUSTOM_LABELS_DESCRIPTION[i]}
|
|
||||||
|
|
||||||
# Set the environment variables in the settings
|
# Set the environment variables in the settings
|
||||||
get_settings().set("OPENAI.KEY", OPENAI_KEY)
|
get_settings().set("OPENAI.KEY", OPENAI_KEY)
|
||||||
@ -114,5 +93,31 @@ async def run_action():
|
|||||||
await PRAgent().handle_request(url, body)
|
await PRAgent().handle_request(url, body)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_custom_labels(CUSTOM_LABELS, CUSTOM_LABELS_DESCRIPTION):
|
||||||
|
if CUSTOM_LABELS:
|
||||||
|
CUSTOM_LABELS = [x.strip() for x in CUSTOM_LABELS.split(',')]
|
||||||
|
else:
|
||||||
|
# Set default labels
|
||||||
|
CUSTOM_LABELS = ['Bug fix', 'Tests', 'Bug fix with tests', 'Refactoring', 'Enhancement', 'Documentation',
|
||||||
|
'Other']
|
||||||
|
print(f"Using default labels: {CUSTOM_LABELS}")
|
||||||
|
if CUSTOM_LABELS_DESCRIPTION:
|
||||||
|
CUSTOM_LABELS_DESCRIPTION = [x.strip() for x in CUSTOM_LABELS_DESCRIPTION.split(',')]
|
||||||
|
else:
|
||||||
|
# Set default labels
|
||||||
|
CUSTOM_LABELS_DESCRIPTION = ['Fixes a bug in the code', 'Adds or modifies tests',
|
||||||
|
'Fixes a bug in the code and adds or modifies tests',
|
||||||
|
'Refactors the code without changing its functionality',
|
||||||
|
'Adds new features or functionality',
|
||||||
|
'Adds or modifies documentation',
|
||||||
|
'Other changes that do not fit in any of the above categories']
|
||||||
|
print(f"Using default labels: {CUSTOM_LABELS_DESCRIPTION}")
|
||||||
|
# create a dictionary of labels and descriptions
|
||||||
|
CUSTOM_LABELS_DICT = dict()
|
||||||
|
for i in range(len(CUSTOM_LABELS)):
|
||||||
|
CUSTOM_LABELS_DICT[CUSTOM_LABELS[i]] = {'description': CUSTOM_LABELS_DESCRIPTION[i]}
|
||||||
|
return CUSTOM_LABELS_DICT
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
asyncio.run(run_action())
|
asyncio.run(run_action())
|
Reference in New Issue
Block a user