Skip to content

Commit

Permalink
fixup getting the Actor's email address
Browse files Browse the repository at this point in the history
We can simply use the integrations app id for the email address
  • Loading branch information
jonathansick committed Oct 7, 2024
1 parent 990a14d commit 4f8084b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/templatebot/services/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ async def create_project_from_template( # noqa: PLR0915 C901
git_repo = GitClone.init_repo(
path=project_dir, github_client=github_client
)
bot_actor = await git_repo.create_bot_actor()
git_repo.commit("Initial commit", actor=bot_actor)
git_repo.commit("Initial commit")
git_repo.push(remote_url=github_repo_url, branch="main")

# Create a Markdown code block showing the template variable names
Expand Down
15 changes: 7 additions & 8 deletions src/templatebot/storage/gitclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,17 @@ def add_remote(self, url: str, *, name: str = "origin") -> git.Remote:
authed_url = self._create_authed_url(url)
return self._repo.create_remote(name, authed_url)

async def create_bot_actor(self) -> git.Actor:
def create_bot_actor(self) -> git.Actor:
"""Create an actor for the bot."""
username = config.github_username
response = await self._github_client.getitem(
"/users{/user}", url_vars={"user": username}
email = (
f"{config.github_app_id}+{config.github_username}"
"[bot]@users.noreply.github.com"
)
uid = str(response["id"])
email = f"{uid}+{username}@users.noreply.github.com"
return git.Actor(username, email)
return git.Actor(config.github_username, email)

def commit(self, message: str, *, actor: git.Actor) -> None:
def commit(self, message: str) -> None:
"""Commit all changes in the repository."""
actor = self.create_bot_actor()
self._repo.index.commit(message, author=actor, committer=actor)

def push(self, *, remote_url: str, branch: str = "main") -> None:
Expand Down

0 comments on commit 4f8084b

Please sign in to comment.