diff --git a/dev.sh b/dev.sh index d721dce..6d86eaf 100755 --- a/dev.sh +++ b/dev.sh @@ -15,7 +15,7 @@ git push --set-upstream origin "$BRANCH" gh pr create --title "[TEST] - PR $ID" --body "" -python src/main.py +#python src/main.py #gh pr view # #git checkout main diff --git a/short_commit_sha b/short_commit_sha new file mode 100644 index 0000000..713337f --- /dev/null +++ b/short_commit_sha @@ -0,0 +1 @@ +305a1a4 diff --git a/src/GitHub/outputs.py b/src/GitHub/outputs.py index 004ea85..8b580d5 100644 --- a/src/GitHub/outputs.py +++ b/src/GitHub/outputs.py @@ -1,4 +1,5 @@ import os +import logging def set_action_outputs(output_pairs): diff --git a/src/GitHub/pullrequest.py b/src/GitHub/pullrequest.py index 26d9d2b..c3b348d 100644 --- a/src/GitHub/pullrequest.py +++ b/src/GitHub/pullrequest.py @@ -1,5 +1,6 @@ import requests import subprocess +import logging from github import Github @@ -52,11 +53,5 @@ def diff(self): response = requests.get(diff_url) return response.text - -# def change_pull_request_description(pr_number, new_description): -# g = Github() -# owner, repo = get_owner_and_repo() -# repository = g.get_repo(f'{owner}/{repo}') -# -# pull_request = repository.get_pull(pr_number) -# pull_request.edit(body=new_description) + def update_description(self, new_description): + self.__pulls.edit(body=new_description) diff --git a/src/OpenAI/model.py b/src/OpenAI/model.py index 39624d1..98b5d63 100644 --- a/src/OpenAI/model.py +++ b/src/OpenAI/model.py @@ -1,6 +1,7 @@ import os import sys import openai +import logging class AiRequest: @@ -34,7 +35,7 @@ def _template(template, template_file_path): return " " # should exit fail def generate_description(self, text): - data = self.__header + self.__template + "\n\n\n" + text + data = self.__header + self.__template + "\n\n" + text openai.api_key = self.__key response = openai.Completion.create( model=self.__model, diff --git a/src/main.py b/src/main.py index 2b9c96f..f2c9808 100755 --- a/src/main.py +++ b/src/main.py @@ -3,9 +3,9 @@ This module generates a pull request description using the OpenAI GPT-3.5 language model. """ -import logging import os import sys +import logging import configuration.logs as logs import configuration.parse as parse @@ -37,10 +37,10 @@ def main(): logging.debug(ai) description = ai.generate_description(patch) -# #print(f"text={description}") -# print(pr.number) -# description="hey!" -# gh.change_pull_request_description(pr.number, description) + logging.debug(description) + outputs.set_action_outputs({"text": f"{description}"}) + + pullrequest.update_description(description) if __name__ == '__main__':