diff --git a/README.md b/README.md
index 4b00913..3520d30 100644
--- a/README.md
+++ b/README.md
@@ -2,19 +2,6 @@
-# Bartholomew "The Butler" Smith
-
-Bartholomew "The Butler" Smith is your personal assistant for managing your GitHub repositories.
-This app automates repetitive tasks, helping you save time and focus on what’s important.
-Here’s what GitHub Butler can do for you:
-- **[Pull Request Management](pull-request)**: Automatically creates a pull request on the repository's default branch
- when a branch is created among other things.
-- Releaser WiP
-- Issue Manager WiP
-
-With Bartholomew "The Butler" Smith, you can spend less time managing your repository and more time writing great code.
-It’s like having a butler for your GitHub repository! :tophat:
-
[![Code Quality](https://github.com/heitorpolidoro/bartholomew-smith/actions/workflows/code_quality.yml/badge.svg)](https://github.com/heitorpolidoro/bartholomew-smith/actions/workflows/code_quality.yml)
[![Latest Version](https://img.shields.io/github/v/release/heitorpolidoro/bartholomew-smith?label=Latest%20Version)](https://github.com/heitorpolidoro/bartholomew-smith/releases/latest)
@@ -33,14 +20,21 @@ It’s like having a butler for your GitHub repository! :tophat:
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=heitorpolidoro_bartholomew-smith&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=heitorpolidoro_bartholomew-smith)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=heitorpolidoro_bartholomew-smith&metric=bugs)](https://sonarcloud.io/summary/new_code?id=heitorpolidoro_bartholomew-smith)
+# Bartholomew "The Butler" Smith
+
+Bartholomew "The Butler" Smith is your personal assistant for managing your GitHub repositories.
+This app automates repetitive tasks, helping you save time and focus on what’s important.
+Here’s what GitHub Butler can do for you:
+- **[Pull Request Manager](../../wiki/Pull-Request-Manager.md)**: Automatically creates a pull request with the repository's default branch as base
+ when a branch is created among other things.
+- Releaser WiP
+- Issue Manager WiP
+
+With Bartholomew "The Butler" Smith, you can spend less time managing your repository and more time writing great code.
+It’s like having a butler for your GitHub repository! :tophat:
+
+See the [Wiki](../../wiki/Home.md) for more information
+
## Thanks to
[gabriellamas](https://github.com/gabriellamas) for helping me with logo ideas
-## TODOs
-- [ ] Self-Approver heitorpolidoro/bartholomew-smith#4
-- [ ] Auto Release heitorpolidoro/bartholomew-smith#5
-- [ ] Issue Manager heitorpolidoro/bartholomew-smith#6
-- [ ] Auto-fix linter heitorpolidoro/bartholomew-smith#84
-- [ ] Check for TODOs in repository (create issues?) heitorpolidoro/bartholomew-smith#83
-- [ ] Dont Merge Yet if WiP or has a not checked item in the checklist heitorpolidoro/bartholomew-smith#86
-- [ ] PR checklist heitorpolidoro/bartholomew-smith#87
diff --git a/app.py b/app.py
index 01c5666..8ec3ed4 100644
--- a/app.py
+++ b/app.py
@@ -4,7 +4,7 @@
import markdown
import sentry_sdk
-from flask import Flask, abort, render_template
+from flask import Flask, render_template
from githubapp import Config, webhook_handler
from githubapp.events import (
CheckSuiteRequestedEvent,
@@ -86,19 +86,8 @@ def handle_issue(event: IssuesEvent):
@app.route("/", methods=["GET"])
def index():
"""Return the index homepage"""
- return file("README.md")
-
-
-@app.route("/", methods=["GET"])
-def file(filename):
- """Convert a md file into HTML and return it"""
- allowed_files = {f: f for f in ["README.md", "pull-request.md"]}
- if filename not in allowed_files:
- abort(404)
- with open(allowed_files[filename]) as f:
+ with open("README.md") as f:
md = f.read()
body = markdown.markdown(md)
title = "Bartholomew Smith"
- if filename != "README.md":
- title += f" - {filename.replace('-', ' ').replace('.md', '').title()}"
return render_template("index.html", title=title, body=body)
diff --git a/src/helpers/pull_request.py b/src/helpers/pull_request.py
index 49e3712..37e26f1 100644
--- a/src/helpers/pull_request.py
+++ b/src/helpers/pull_request.py
@@ -58,7 +58,7 @@ def create_pull_request(repository: Repository, branch: str) -> Optional[PullReq
repository.default_branch,
branch,
title=title or branch,
- body=body or "PR automatically created",
+ body=body or "Pull Request automatically created",
draft=False,
)
return pr
@@ -102,10 +102,3 @@ def get_or_create_pull_request(
pr = create_pull_request(repository, branch)
return pr
-
-def enable_auto_merge(pr: PullRequest) -> None:
- """
- Enables auto merge for the given PR.
- :param pr: The PR to enable auto merge for.
- """
- pr.enable_automerge(merge_method="SQUASH")
diff --git a/src/managers/pull_request.py b/src/managers/pull_request.py
index f11f5e9..e398be8 100644
--- a/src/managers/pull_request.py
+++ b/src/managers/pull_request.py
@@ -10,5 +10,6 @@
def handle_create_pull_request(repository: Repository, branch: str):
"""Creates a Pull Request, if not exists, and/or enable the auto merge flag"""
if repository.default_branch != branch:
- pr = pull_request.get_or_create_pull_request(repository, branch)
- pull_request.enable_auto_merge(pr)
+ pull_request.get_or_create_pull_request(repository, branch).enable_automerge(
+ merge_method="SQUASH"
+ )
diff --git a/tests/helpers/test_pull_request.py b/tests/helpers/test_pull_request.py
index 4417999..6827b5b 100644
--- a/tests/helpers/test_pull_request.py
+++ b/tests/helpers/test_pull_request.py
@@ -5,11 +5,12 @@
from src.helpers.pull_request import (
create_pull_request,
- enable_auto_merge,
get_existing_pull_request,
get_or_create_pull_request,
)
+OTHER_ERROR = "other error"
+
def test_get_existing_pull_request_when_there_is_none(repository):
repository.get_pulls.return_value = []
@@ -30,7 +31,7 @@ def test_create_pull_request(repository):
repository.default_branch,
"branch",
title="branch",
- body="PR automatically created",
+ body="Pull Request automatically created",
draft=False,
)
@@ -65,20 +66,20 @@ def test_create_pull_request_when_there_is_no_commits(repository):
def test_create_pull_request_when_other_errors(repository):
repository.create_pull.side_effect = GithubException(
- status=400, message="other error"
+ status=400, message=OTHER_ERROR
)
with pytest.raises(GithubException) as err:
create_pull_request(repository, "branch")
- assert err.value.message == "other error"
+ assert err.value.message == OTHER_ERROR
def test_create_pull_request_when_other_errors2(repository):
repository.create_pull.side_effect = GithubException(
- status=400, data={"errors": [{"message": "other error"}]}
+ status=400, data={"errors": [{"message": OTHER_ERROR}]}
)
with pytest.raises(GithubException) as err:
create_pull_request(repository, "branch")
- assert err.value.data["errors"][0]["message"] == "other error"
+ assert err.value.data["errors"][0]["message"] == OTHER_ERROR
def test_get_or_create_pull_request_when_there_is_no_pull_request(repository):
@@ -116,7 +117,4 @@ def test_get_or_create_pull_request_when_there_is_a_pull_request(repository):
create_pull_request_mock.assert_not_called()
-def test_enable_auto_merge():
- pull_request = Mock()
- enable_auto_merge(pull_request)
- pull_request.enable_automerge.assert_called_once_with(merge_method="SQUASH")
+
diff --git a/tests/managers/test_pull_request.py b/tests/managers/test_pull_request.py
index 9e5adb4..a7c8069 100644
--- a/tests/managers/test_pull_request.py
+++ b/tests/managers/test_pull_request.py
@@ -18,7 +18,7 @@ def test_handle_create_pull_request(pull_request_helper):
repository, "branch"
)
pr = pull_request_helper.get_or_create_pull_request.return_value
- pull_request_helper.enable_auto_merge.assert_called_once_with(pr)
+ pr.enable_automerge.assert_called_once_with(merge_method="SQUASH")
def test_handle_create_pull_request_ignore_when_head_branch_is_the_default_branch(
diff --git a/tests/test_app.py b/tests/test_app.py
index 7da939e..8c57bae 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -99,21 +99,6 @@ def test_index(self):
"index.html", title="Bartholomew Smith", body=body
)
- def test_file(self):
- response = self.client.get("/pull-request.md")
- assert response.status_code == 200
- with open("pull-request.md") as f:
- md = f.read()
- body = markdown.markdown(md)
- self.mock_render_template.assert_called_once_with(
- "index.html", title="Bartholomew Smith - Pull Request", body=body
- )
-
- def test_file_security(self):
- response = self.client.get("/other.txt")
- assert response.status_code == 404
- self.mock_render_template.assert_not_called()
-
def test_managers_disabled(
handle_create_pull_request_mock, handle_release_mock, handle_tasklist_mock