Skip to content

Commit

Permalink
- Experiments.
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpojer committed Jun 25, 2024
1 parent a758daf commit b2c6b35
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/github_integration/gh_api_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ def fetch_finished_pull_requests(repo: Repository) -> list[PullRequest]:


def fetch_commits(repo: Repository) -> list[Commit]:
logging.info(f"Fetching all closed PRs for {repo.full_name}")
logging.info(f"Fetching all commits {repo.full_name}")
raw_commits = repo.get_commits()

commits = []
for raw_commit in raw_commits:
# for reference commit auhtor - use raw_commit.author

logging.debug(f"Raw Commit: {raw_commit}, Author: {raw_commit.author}, Commiter: {raw_commit.committer}.")
logging.debug(f"Raw Commit.commit: Message: {raw_commit.commit.message}, Author: {raw_commit.commit.author}, Commiter: {raw_commit.commit.committer}.")

commits.append(Commit(raw_commit))

return commits
Expand Down
4 changes: 4 additions & 0 deletions src/github_integration/model/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
class Commit:
def __init__(self, commit: GitCommit):
self.__commit: GitCommit = commit

@property
def sha(self) -> str:
return self.__commit.sha
4 changes: 4 additions & 0 deletions src/github_integration/model/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def contributors(self) -> list[str]:
# TODO
return []

@property
def merge_commit_sha(self) -> str:
return self.__source_pull.merge_commit_sha

def extract_issue_numbers_from_body(self) -> list[int]:
# Regex pattern to match issue numbers following keywords like "Close", "Fix", "Resolve"
regex_pattern = re.compile(r'([Cc]los(e|es|ed)|[Ff]ix(es|ed)?|[Rr]esolv(e|es|ed))\s*#\s*([0-9]+)')
Expand Down
6 changes: 4 additions & 2 deletions src/release_notes/factory/record_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ def generate(issues: list[Issue], pulls: list[PullRequest], commits: list[Commit
records[pull.number].register_pull_request(pull)
logging.debug(f"Created record for PR {pull.number}: {pull.title}")

# for commit in commits:
# logging.debug(f"Registering commit {commit.message} to Issue {commit.issue_number}")
for commit in commits:
for pull in pulls:
if commit.sha in pull.merge_commit_sha:
logging.debug("Commit SHA found in Pull merge commit SHA for PR {pull.number}.")

logging.info(f"Generated {len(records)} records from {len(issues)} issues and {len(pulls)} PRs.")
return records

0 comments on commit b2c6b35

Please sign in to comment.