Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/command-ref.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Check the command reference
run: uvx --from rust-just@1.52.0 just command-ref
run: uvx --from rust-just@1.57.0 just command-ref
2 changes: 1 addition & 1 deletion .github/workflows/functional-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
env:
UV_PYTHON: ${{ matrix.python-version }}
GITHUB_TOKEN: ${{ secrets.DWILDING_GITHUB_TOKEN }}
run: uvx --from rust-just@1.52.0 just functional
run: uvx --from rust-just@1.57.0 just functional
2 changes: 1 addition & 1 deletion .github/workflows/functional-limited.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: Run functional tests
env:
UV_PYTHON: '3.10'
run: uvx --from rust-just@1.52.0 just functional
run: uvx --from rust-just@1.57.0 just functional
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Lint the code
run: uvx --from rust-just@1.52.0 just lint
run: uvx --from rust-just@1.57.0 just lint
2 changes: 1 addition & 1 deletion .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: Run unit tests
env:
UV_PYTHON: ${{ matrix.python-version }}
run: uvx --from rust-just@1.52.0 just unit
run: uvx --from rust-just@1.57.0 just unit
1 change: 1 addition & 0 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Runtime dependencies:
- [pre-commit](https://github.com/pre-commit/pre-commit/releases)
- [PyGithub](https://github.com/PyGithub/PyGithub/releases)
- [PyJWT](https://github.com/jpadilla/pyjwt/releases)
- [cryptography](https://github.com/pyca/cryptography/releases)
- [requests](https://github.com/psf/requests/releases)

Development dependencies:
Expand Down
17 changes: 9 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "gimmegit"
version = "3.0.1.dev0"
version = "3.0.1"
description = "A tool for cloning GitHub repos and creating branches."
authors = [
{ name = "Dave Wilding", email = "tech@dpw.me" },
Expand All @@ -9,11 +9,12 @@ license = "MIT"
license-files = ["LICENSE"]
requires-python = ">=3.10"
dependencies = [
"gitpython==3.1.50",
"pre-commit==4.6.0",
"gitpython==3.1.57",
"pre-commit==4.6.1",
"PyGithub==2.9.1",
# Dependencies of PyGithub. Specified because of security advisories.
"PyJWT[crypto]==2.13.0",
"cryptography==48.0.1",
"requests==2.34.2",
]

Expand All @@ -22,15 +23,15 @@ gimmegit = "gimmegit._cli:main"

[dependency-groups]
dev = [
"ruff==0.15.16",
"pytest==9.0.3",
"ty==0.0.44",
"zizmor==1.25.2",
"ruff==0.16.0",
"pytest==9.1.1",
"ty==0.0.65",
"zizmor==1.28.0",
]

[build-system]
requires = [
"uv_build==0.11.19",
"uv_build==0.12.0",
]
build-backend = "uv_build"

Expand Down
4 changes: 2 additions & 2 deletions src/gimmegit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from ._parse import parse_url, ParsedURL
from ._parse import ParsedURL, parse_url
from ._version import __version__

__all__ = [
"ParsedURL",
"__version__",
"parse_url",
"ParsedURL",
]
2 changes: 1 addition & 1 deletion src/gimmegit/_args.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
import argparse
from dataclasses import dataclass

CHOICES = ["auto", "always", "never"]
DEFAULT_CHOICE = "auto"
Expand Down
20 changes: 12 additions & 8 deletions src/gimmegit/_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import NoReturn
import argparse
import concurrent.futures
import logging
Expand All @@ -12,6 +8,10 @@
import sys
import tempfile
import webbrowser
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import NoReturn

import git
import github
Expand Down Expand Up @@ -195,6 +195,7 @@ def compare_usage(status: _status.Status) -> None:
["xdg-open", status.compare_url],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=False,
)
if result.returncode:
logger.log(DATA_LEVEL, status.compare_url)
Expand Down Expand Up @@ -580,7 +581,7 @@ def make_github_url(repo: str) -> str:
return repo
if repo.count("/") == 1 and not repo.endswith("/"):
return f"https://github.com/{repo}"
if repo.endswith("/") or repo.endswith("\\"):
if repo.endswith(("/", "\\")):
project = repo[:-1] # The user might have tab-completed a project dir.
else:
project = repo
Expand Down Expand Up @@ -616,7 +617,7 @@ def make_shallow_date(context: Context) -> str:


def make_snapshot_name() -> str:
today = datetime.now()
today = datetime.now(tz=timezone.utc).astimezone()
today_formatted = today.strftime("%m%d")
return f"snapshot{today_formatted}"

Expand Down Expand Up @@ -705,7 +706,11 @@ def primary_usage(args: argparse.Namespace, fetch_opts: list[str]) -> None:
def probe_branch(context: Context) -> None:
with tempfile.TemporaryDirectory() as empty_dir:
try:
if git.Git(empty_dir).ls_remote(context.clone_url, context.branch, heads=True).strip():
remote_refs = git.Git(empty_dir).ls_remote(
context.clone_url, context.branch, heads=True
)
assert isinstance(remote_refs, str)
if remote_refs.strip():
raise CloneError(f"The repo already has a branch {f_blue(context.branch)}.")
except git.GitCommandError as e:
if is_access_error(e):
Expand All @@ -714,7 +719,6 @@ def probe_branch(context: Context) -> None:


def set_global_color(color_arg: str) -> None:
global COLOR
if color_arg == "auto":
COLOR["stdout"] = os.isatty(sys.stdout.fileno()) and not bool(os.getenv("NO_COLOR"))
COLOR["stderr"] = os.isatty(sys.stderr.fileno()) and not bool(os.getenv("NO_COLOR"))
Expand Down
2 changes: 1 addition & 1 deletion src/gimmegit/_parse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
import re
import urllib.parse
from dataclasses import dataclass

from . import _remote

Expand Down
2 changes: 1 addition & 1 deletion src/gimmegit/_status.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
import urllib.parse
from dataclasses import dataclass

import git

Expand Down
2 changes: 1 addition & 1 deletion src/gimmegit/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.1.dev0"
__version__ = "3.0.1"
4 changes: 2 additions & 2 deletions tests/functional/helpers_functional.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from pathlib import Path
import os
import subprocess
import types

from pathlib import Path

no_ssh = ["--ssh", "never"]

Expand Down Expand Up @@ -69,6 +68,7 @@ def get_ref_exists(dir: Path, ref: str) -> bool:
result = subprocess.run(
["git", "show-ref", "--verify", "--quiet", ref],
cwd=dir,
check=False,
)
return result.returncode == 0

Expand Down
12 changes: 12 additions & 0 deletions tests/functional/test_arg_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_no_repo(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -32,6 +33,7 @@ def test_missing_upstream_owner(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -53,6 +55,7 @@ def test_missing_base_branch(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -74,6 +77,7 @@ def test_missing_color(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -96,6 +100,7 @@ def test_invalid_color(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -117,6 +122,7 @@ def test_missing_ssh(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -139,6 +145,7 @@ def test_invalid_ssh(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -160,6 +167,7 @@ def test_repo_with_compare(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -181,6 +189,7 @@ def test_repo_with_help(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -202,6 +211,7 @@ def test_repo_with_version(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand Down Expand Up @@ -231,6 +241,7 @@ def test_status_unexpected(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand All @@ -252,6 +263,7 @@ def test_parse_unsupported(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 2
assert not result.stdout
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_bare_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def test_compre_no_outer(uv_run, test_dir):
cwd=test_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 1
assert not result.stdout
Expand Down
8 changes: 6 additions & 2 deletions tests/functional/test_clone.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import date, datetime
import subprocess
from datetime import date

import helpers_functional as helpers

Expand Down Expand Up @@ -203,6 +203,7 @@ def test_existing_clone(uv_run, test_dir):
env=helpers.default_env(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 10
expected_dir = test_dir / "jubilant/dwilding-my-feature"
Expand Down Expand Up @@ -266,6 +267,7 @@ def test_dashboard_warning(uv_run, test_dir):
cwd=working_dir,
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 11
expected_stdout = """\
Expand Down Expand Up @@ -314,6 +316,7 @@ def test_compare_no_remote(uv_run, test_dir):
cwd=working_dir,
capture_output=True,
text=True,
check=False,
)
assert not result.stdout
expected_stderr = """\
Expand All @@ -340,6 +343,7 @@ def test_in_project_dir(uv_run, test_dir):
env=helpers.default_env(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 1
expected_stdout = """\
Expand Down Expand Up @@ -516,5 +520,5 @@ def test_jumbo(uv_run, test_dir):
"""
assert result.stdout == expected_stdout
raw_commit_date = helpers.get_first_commit_date(expected_dir)
commit_date = datetime.strptime(raw_commit_date, "%Y-%m-%d").date()
commit_date = date.fromisoformat(raw_commit_date)
assert commit_date > date(2026, 1, 1)
Loading
Loading