2025-02-23 daily publish

This commit is contained in:
matt 2025-02-23 19:06:07 -08:00
parent 01862d2120
commit 9ab1a23ff4
4 changed files with 58 additions and 1 deletions

View File

@ -7,6 +7,7 @@ authors = [{ name = "GitMatt", email = "git@publicmatt.com" }]
requires-python = ">=3.12"
dependencies = [
"click>=8.1.8",
"invoke>=2.2.0",
"option>=2.1.0",
"pydanclick>=0.4.0",
"pydantic>=2.10.6",

View File

@ -1,7 +1,7 @@
import click
from pydanclick import from_pydantic
from . import weather, hacker_news
from . import weather, hacker_news, git
@click.group()
@ -26,3 +26,6 @@ def top():
stories = hacker_news.recent_top_stories()
for item in stories:
print(f"[{item.score:>4}|{item.diff_for_humans():>12}]: {item.title}")
cli.add_command(git.cli)

42
src/daily/git.py Normal file
View File

@ -0,0 +1,42 @@
import os
import subprocess
import os
import click
from pathlib import Path
from datetime import datetime
import logging
@click.command("commit-push")
@click.option(
"--repo-path", "-p", "repo_path", help="path to commit", default=Path().cwd()
)
def cli(repo_path):
"""
Commits and pushes changes in the specified Git repository.
"""
commit_message = f"{datetime.now().strftime('%Y-%m-%d')} daily publish"
os.chdir(repo_path)
try:
# Run git add (add all changes)
subprocess.run(["git", "add", "."], check=True)
# Run git commit
subprocess.run(["git", "commit", "-m", commit_message], check=True)
# Run git push
subprocess.run(["git", "push"], check=True)
click.echo(
f"changes have been committed and pushed to {repo_path} with message: {commit_message}"
)
logging.info("git pushed")
except subprocess.CalledProcessError as e:
logging.warning(f"error occurred while running git command: {e}")
click.echo(f"error occurred while running git command: {e}")
if __name__ == "__main__":
cli()

11
uv.lock
View File

@ -81,6 +81,7 @@ version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "click" },
{ name = "invoke" },
{ name = "option" },
{ name = "pydanclick" },
{ name = "pydantic" },
@ -91,6 +92,7 @@ dependencies = [
[package.metadata]
requires-dist = [
{ name = "click", specifier = ">=8.1.8" },
{ name = "invoke", specifier = ">=2.2.0" },
{ name = "option", specifier = ">=2.1.0" },
{ name = "pydanclick", specifier = ">=0.4.0" },
{ name = "pydantic", specifier = ">=2.10.6" },
@ -107,6 +109,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442 },
]
[[package]]
name = "invoke"
version = "2.2.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/f9/42/127e6d792884ab860defc3f4d80a8f9812e48ace584ffc5a346de58cdc6c/invoke-2.2.0.tar.gz", hash = "sha256:ee6cbb101af1a859c7fe84f2a264c059020b0cb7fe3535f9424300ab568f6bd5", size = 299835 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/0a/66/7f8c48009c72d73bc6bbe6eb87ac838d6a526146f7dab14af671121eb379/invoke-2.2.0-py3-none-any.whl", hash = "sha256:6ea924cc53d4f78e3d98bc436b08069a03077e6f85ad1ddaa8a116d7dad15820", size = 160274 },
]
[[package]]
name = "option"
version = "2.1.0"