Skip to content

Initialize the PullPal project with core functionality, including fetching and saving GitHub pull request conversations, along with supporting files for configuration, documentation, testing, and CI/CD#1

Merged
TheRealFREDP3D merged 5 commits intomainfrom
initial
May 2, 2025

Conversation

@TheRealFREDP3D
Copy link
Copy Markdown
Owner

@TheRealFREDP3D TheRealFREDP3D commented May 2, 2025

Summary by Sourcery

Initialize the PullPal project, a comprehensive tool for fetching and saving GitHub pull request conversations with robust functionality and supporting infrastructure

New Features:

  • Create a command-line tool to fetch GitHub pull request conversations
  • Support fetching single, multiple, or latest pull requests
  • Implement output in Markdown and JSON formats

Enhancements:

  • Implement pagination handling for GitHub API requests
  • Add flexible configuration options
  • Create error handling mechanisms

Build:

  • Create setup.py for package configuration
  • Define package dependencies and entry points

CI:

  • Set up GitHub Actions for Python package testing
  • Configure workflows for multiple Python versions
  • Add publish workflow for PyPI

Documentation:

  • Create comprehensive README with usage instructions
  • Add CONTRIBUTING.md guidelines
  • Include CHANGELOG.md for version tracking

Tests:

  • Develop comprehensive unit tests for PullPal functionality
  • Add test coverage for different API interaction scenarios

…ching and saving GitHub pull request conversations, along with supporting files for configuration, documentation, testing, and CI/CD
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented May 2, 2025

Reviewer's Guide

This pull request initializes the PullPal project. It adds the core script PullPal.py which uses the requests library to fetch GitHub pull request conversation data (details, issue comments, review comments, reviews) via the API, handling authentication and pagination. It uses argparse for command-line argument processing and supports saving conversations as Markdown or JSON. The PR also includes unit tests (unittest), project setup (setup.py), documentation (README.md, etc.), example usage scripts, and GitHub Actions workflows for CI/CD.

Sequence diagram for fetching a single PR conversation

sequenceDiagram
    actor User
    participant CLI as PullPal Script
    participant GitHubAPI as GitHub API
    participant FileSystem

    User->>+CLI: Executes `pullpal --pr 123`
    CLI->>CLI: parse_args()
    CLI->>CLI: Load GITHUB_TOKEN from .env or args
    CLI->>CLI: get_headers(token)
    CLI->>+GitHubAPI: GET /repos/{owner}/{repo}/pulls/123 (fetch_pr_details)
    GitHubAPI-->>-CLI: PR Details JSON
    CLI->>+GitHubAPI: GET /repos/{owner}/{repo}/pulls/123/comments (fetch_review_comments)
    GitHubAPI-->>-CLI: Review Comments JSON (handles pagination)
    CLI->>+GitHubAPI: GET /repos/{owner}/{repo}/issues/123/comments (fetch_issue_comments)
    GitHubAPI-->>-CLI: Issue Comments JSON (handles pagination)
    CLI->>+GitHubAPI: GET /repos/{owner}/{repo}/pulls/123/reviews (fetch_reviews)
    GitHubAPI-->>-CLI: Reviews JSON (handles pagination)
    Note over CLI: Combines data into 'conversation' dict
    CLI->>CLI: format_conversation_as_markdown(conversation)
    CLI->>+FileSystem: save_conversation(conversation, output_file, 'md')
    FileSystem-->>-CLI: File Saved
    CLI-->>-User: Prints success message with file path
Loading

File-Level Changes

Change Details Files
Implement core GitHub PR conversation fetching logic.
  • Added functions (fetch_pr_details, fetch_review_comments, fetch_issue_comments, fetch_reviews) to interact with specific GitHub API endpoints.
  • Implemented pagination handling for API responses.
  • Created fetch_conversation to aggregate all parts of the PR conversation.
  • Added get_headers to create authentication headers.
pullpal/PullPal.py
Add command-line interface, output formatting, and saving.
  • Implemented argument parsing using argparse to handle user inputs (PR numbers, token, output options, etc.).
  • Added function format_conversation_as_markdown to structure fetched data into Markdown.
  • Added function save_conversation to write conversation data to a file in either Markdown or JSON format.
  • Included functions for basic terminal UI (clear screen, header, loading bar).
  • Added main function orchestrating argument parsing, fetching, and saving.
pullpal/PullPal.py
Introduce unit tests for core functionality.
  • Added test cases using unittest and unittest.mock.
  • Covered functions for fetching data from GitHub API (mocking requests).
  • Tested conversation formatting (format_conversation_as_markdown).
  • Tested conversation saving (save_conversation) for both JSON and Markdown formats.
tests/test_pullpal.py
Set up project structure, packaging, and configuration.
  • Created setup.py for package installation and metadata using setuptools.
  • Added MANIFEST.in to include necessary non-code files in the package.
  • Initialized the pullpal package with __init__.py.
  • Added .gitignore to exclude common Python and environment files.
  • Provided example environment files (.env.example, .env.sample).
setup.py
MANIFEST.in
pullpal/__init__.py
.gitignore
.env.example
.env.sample
Add project documentation and usage examples.
  • Created README.md with usage instructions, features, and installation guide.
  • Added CONTRIBUTING.md with guidelines for contributors.
  • Initialized CHANGELOG.md.
  • Provided example scripts in the examples/ directory.
  • Added an ASCII art header file.
README.md
CONTRIBUTING.md
CHANGELOG.md
examples/save_as_json.py
examples/fetch_latest_prs.py
examples/fetch_specific_prs.py
pullpal/header.md
Implement CI/CD workflows using GitHub Actions.
  • Added workflow (python-package.yml) for linting, testing, and coverage reporting.
  • Added workflow (python-tests.yml) specifically for running tests across multiple Python versions.
  • Added workflow (python-publish.yml) to publish the package to PyPI on release creation.
.github/workflows/python-package.yml
.github/workflows/python-tests.yml
.github/workflows/python-publish.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @TheRealFREDP3D, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request initializes the PullPal project, a tool designed to fetch and save GitHub pull request conversations. It includes core functionality for fetching PR details, issue comments, review comments, and reviews, and saving them in Markdown or JSON format. The PR also sets up supporting files for configuration, documentation, testing, and CI/CD.

Highlights

  • Core Functionality: Implements the core logic for fetching and saving GitHub pull request conversations, including PR details, issue comments, review comments, and reviews.
  • Configuration: Adds .env files for managing GitHub token and other configurations, along with .gitignore to exclude sensitive files.
  • Documentation: Includes README.md, CHANGELOG.md, and CONTRIBUTING.md to provide project information, usage instructions, and contribution guidelines.
  • CLI Interface: Sets up a command-line interface using argparse to allow users to fetch PR conversations with various options.
  • Example Scripts: Provides example scripts to demonstrate how to use PullPal to fetch specific PRs, latest PRs, and save conversations as JSON.
  • Testing: Adds initial tests using unittest to ensure the core functionality of PullPal works as expected.
  • Project Setup: Initializes setup.py for packaging and distribution, and MANIFEST.in to include necessary files.
  • Header: Adds a header to the CLI using the header.md file.

Changelog

Click here to see the changelog
  • .augmentignore
    • Added to ignore .env files
  • .env.example
    • Added example .env file to show how to set the GitHub token
  • .env.sample
    • Added sample .env file to show how to set the GitHub token
  • .gitignore
    • Added to ignore various files and directories, including .env, __pycache__, and IDE-specific files
  • .snapshots/config.json
    • Added configuration file for snapshots, excluding various file types and directories
  • .snapshots/readme.md
    • Added readme for snapshots directory
  • .snapshots/sponsors.md
    • Added sponsors file for snapshots directory
  • CHANGELOG.md
    • Added initial changelog with version 0.1.0 and a list of added features
  • CONTRIBUTING.md
    • Added contributing guidelines, including bug reporting, enhancement suggestions, and pull request instructions
  • MANIFEST.in
    • Added to include necessary files for packaging, such as header.md, LICENSE, README.md, CHANGELOG.md, and .env.example
  • README.md
    • Added comprehensive README with features, requirements, installation, usage examples, and output format
  • examples/fetch_latest_prs.py
    • Added example script to fetch the latest pull requests from a repository
  • examples/fetch_specific_prs.py
    • Added example script to fetch specific pull requests from a repository
  • examples/save_as_json.py
    • Added example script to fetch a pull request and save it as JSON
  • pullpal/PullPal.py
    • Implemented core functionality for fetching and saving PR conversations
    • Added command-line interface using argparse
    • Implemented functions for fetching PR details, comments, reviews, and saving in Markdown or JSON format
    • Added clear_screen, display_header, and display_loading_bar functions for CLI presentation
  • pullpal/init.py
    • Initialized the pullpal package and set the version to 0.1.0
  • pullpal/header.md
    • Added header to the CLI
  • setup.py
    • Added setup script for packaging and distribution
  • test_output/vscode-248031.md
    • Added test output file
  • tests/test_pullpal.py
    • Added initial tests using unittest to ensure core functionality works as expected
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A pull request's tale,
Comments flow, reviews prevail,
Code's journey starts.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces the core functionality for fetching and saving GitHub pull request conversations. The code is well-structured and includes example scripts and tests. However, there are a few areas that could be improved, such as error handling and consistency in string formatting.

Summary of Findings

  • Missing Error Handling: The example scripts lack proper error handling for the os.makedirs function. If the directory creation fails, the script should handle the exception gracefully to prevent unexpected crashes.
  • Inconsistent use of f-strings: While f-strings are used in some parts of the code, there are instances where older string formatting methods are used. Consistent use of f-strings would improve readability and maintainability.
  • Hardcoded values: The example scripts use hardcoded values for owner, repo, and output directory. Consider using command-line arguments or a configuration file to make these values configurable.

Merge Readiness

The pull request is almost ready for merging. Addressing the missing error handling and inconsistencies in string formatting would improve the code quality. I am unable to approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.

Comment thread pullpal/PullPal.py Outdated
Comment thread examples/fetch_latest_prs.py Outdated
Comment thread examples/fetch_specific_prs.py Outdated
Comment thread examples/save_as_json.py Outdated
TheRealFREDP3D and others added 4 commits May 2, 2025 14:11
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@TheRealFREDP3D TheRealFREDP3D merged commit f8a06de into main May 2, 2025
4 of 10 checks passed
TheRealFREDP3D added a commit that referenced this pull request May 2, 2025
Merge pull request #1 from TheRealFREDP3D/initial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant