Author SHA1 Message Date
GitHub Actions 91077fa527 Merge remote-tracking branch 'origin/main' into backups_helper
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.12.3) (pull_request) Successful in 35s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.13) (pull_request) Successful in 37s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.14) (pull_request) Successful in 40s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.12.3) (pull_request) Successful in 35s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.13) (pull_request) Successful in 36s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.14) (pull_request) Successful in 38s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.12.3) (pull_request) Successful in 1m43s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.13) (pull_request) Successful in 1m42s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.14) (pull_request) Successful in 1m45s
Python package / build (pip list, 3.12.3) (pull_request) Successful in 34s
Python package / build (pip list, 3.13) (pull_request) Successful in 36s
Python package / build (pip list, 3.14) (pull_request) Successful in 37s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.12.3) (pull_request) Successful in 32s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.13) (pull_request) Successful in 37s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.14) (pull_request) Successful in 38s
Python package / tests (pytest, 3.12.3) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.13) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.14) (pull_request) Canceled after 0s
2026-08-04 12:29:42 +00:00
GitHub Actions 8ffbb96c37 Squash 2026-06-11 20:35:58 +00:00
19 changed files with 185 additions and 251 deletions
-4
View File
@@ -17,7 +17,3 @@
state: str # 'Active' or 'Pause'
pipeline: Dict[str, Any]
fdsf
+61
View File
@@ -0,0 +1,61 @@
from steps.git import GitClone, CheckoutMerged, GitUnmerge
from steps.docker import DockerSwarmCheck, DockerSwarmDeploy
from enironment import Environment
from steps.checks import SimpleLog, UrlCheck
from steps.shared_state import SharedStateHolderInMemory
clone = GitClone(url="https://github.com/rudolf1/uber_backup.git", branchNamePrefix="photosHelper")
sharedState = SharedStateHolderInMemory(unmerge=None)
checkoutMerged = CheckoutMerged(clone,
desired_branches=sharedState,
push = False,
git_user_email="rudolfss13@gmail.com",
git_user_name="brencher_bot"
)
sharedState.set_branches([("photosHelper/master", "HEAD")])
dockerSwarmCheck = DockerSwarmCheck(
stack_name = "photosHelper",
)
deployDocker = DockerSwarmDeploy(
wd=clone,
buildDocker=None,
stackChecker=dockerSwarmCheck,
envs = lambda: {
"version": "auto-" + checkoutMerged.progress().version
},
stack_name = "photosHelper",
docker_compose_path = "docker-compose.yml",
)
unmerge = GitUnmerge(clone, dockerSwarmCheck)
checkPing = UrlCheck(
url="https://backuper.rudolf.keenetic.link/api/server/ping",
expected = {"res":"pong"},
)
logUrls = SimpleLog(message = {
"userLinks": {
"App": "https://backuper.rudolf.keenetic.link",
}
})
backups_helper = Environment(
id="backupsHelper",
state=sharedState,
pipeline=[
clone,
sharedState,
checkoutMerged,
dockerSwarmCheck,
unmerge,
deployDocker,
checkPing,
logUrls
]
)
+5 -5
View File
@@ -45,10 +45,10 @@ deployDocker = DockerSwarmDeploy(
docker_compose_path="docker-compose.yml",
)
#checkPing = UrlCheck(
# url="https://brencher.rudolf.keenetic.link/state",
# expected=checkPingF,
#)
checkPing = UrlCheck(
url="https://brencher.rudolf.keenetic.link/state",
expected=checkPingF,
)
logUrls = SimpleLog(message={
"userLinks": {
"App": "https://brencher.rudolf.keenetic.link/",
@@ -68,7 +68,7 @@ brencher = Environment(
dockerSwarmCheck,
unmerge,
deployDocker,
# checkPing,
checkPing,
logUrls
]
)
+5 -5
View File
@@ -72,10 +72,10 @@ deployDocker = DockerSwarmDeploy(
docker_compose_path="docker-compose.yml",
)
#checkPing = UrlCheck(
# url="https://brencher.rudolf.keenetic.link/state",
# expected=checkPingF,
#)
checkPing = UrlCheck(
url="https://brencher.rudolf.keenetic.link/state",
expected=checkPingF,
)
logUrls = SimpleLog(message={
"userLinks": {
"App": "https://brencher.rudolf.keenetic.link/",
@@ -98,7 +98,7 @@ brencher2 = Environment(
dockerSwarmCheck,
unmerge,
deployDocker,
# checkPing,
checkPing,
logUrls
],
)
-59
View File
@@ -1,59 +0,0 @@
from enironment import Environment
from steps.checks import SimpleLog, UrlCheck
from steps.docker import DockerSwarmCheck, DockerSwarmDeploy
from steps.git import GitClone, CheckoutMerged, GitUnmerge
from steps.shared_state import SharedStateHolderInMemory
clone = GitClone(url="https://github.com/rudolf1/uber_backup.git", branchNamePrefix="ansible")
dockerSwarmCheck = DockerSwarmCheck(
stack_name="gitea",
)
unmerge = GitUnmerge(clone, dockerSwarmCheck)
state = SharedStateHolderInMemory(unmerge=unmerge)
checkoutMerged = CheckoutMerged(clone,
desired_branches=state,
push=False,
git_user_email="rudolfss13@gmail.com",
git_user_name="brencher_bot"
)
deployDocker = DockerSwarmDeploy(
wd=clone,
buildDocker=None,
stackChecker=dockerSwarmCheck,
envs=lambda: {
"version": "auto-" + checkoutMerged.progress().version,
},
stack_name="gitea",
docker_compose_path="poc/gitea/stack-compose.yml",
)
# checkPing1 = UrlCheck(
# url="http://100.70.193.97:8087/api/status",
# expected=lambda obj: obj['gateway_running'] == 'true' and obj['auth_required'] == 'true',
# )
logUrls = SimpleLog(message={
"userLinks": {
"App": "https://gitea.rudolf.keenetic.link",
}
})
__all__ = ["gitea"]
gitea = Environment(
id="gitea",
state=state,
pipeline=[
clone,
state,
checkoutMerged,
dockerSwarmCheck,
unmerge,
deployDocker,
# checkPing1,
logUrls
]
)
-59
View File
@@ -1,59 +0,0 @@
from enironment import Environment
from steps.checks import SimpleLog, UrlCheck
from steps.docker import DockerSwarmCheck, DockerSwarmDeploy
from steps.git import GitClone, CheckoutMerged, GitUnmerge
from steps.shared_state import SharedStateHolderInMemory
clone = GitClone(url="https://github.com/rudolf1/uber_backup.git", branchNamePrefix="ansible")
dockerSwarmCheck = DockerSwarmCheck(
stack_name="hermes",
)
unmerge = GitUnmerge(clone, dockerSwarmCheck)
state = SharedStateHolderInMemory(unmerge=unmerge)
checkoutMerged = CheckoutMerged(clone,
desired_branches=state,
push=False,
git_user_email="rudolfss13@gmail.com",
git_user_name="brencher_bot"
)
deployDocker = DockerSwarmDeploy(
wd=clone,
buildDocker=None,
stackChecker=dockerSwarmCheck,
envs=lambda: {
"version": "auto-" + checkoutMerged.progress().version,
},
stack_name="hermes",
docker_compose_path="poc/hermes/stack-compose.yml",
)
checkPing1 = UrlCheck(
url="http://100.70.193.97:8087/api/status",
expected=lambda obj: obj['gateway_running'] == 'true' and obj['auth_required'] == 'true',
)
logUrls = SimpleLog(message={
"userLinks": {
"App": "https://hermes.rudolf.keenetic.link",
}
})
__all__ = ["hermes"]
hermes = Environment(
id="hermes",
state=state,
pipeline=[
clone,
state,
checkoutMerged,
dockerSwarmCheck,
unmerge,
deployDocker,
checkPing1,
logUrls
]
)
-73
View File
@@ -1,73 +0,0 @@
from enironment import Environment
from steps.checks import SimpleLog, UrlCheck
from steps.docker import DockerComposeBuild, DockerSwarmCheck, DockerSwarmDeploy
from steps.git import GitClone, CheckoutMerged, GitUnmerge
from steps.shared_state import SharedStateHolderInMemory
clone = GitClone(url="https://github.com/rudolf1/uber_backup.git", branchNamePrefix="ansible")
dockerSwarmCheck = DockerSwarmCheck(
stack_name="hermes_infra",
)
unmerge = GitUnmerge(clone, dockerSwarmCheck)
state = SharedStateHolderInMemory(unmerge=None)
checkoutMerged = CheckoutMerged(clone,
desired_branches=state,
push=False,
git_user_email="rudolfss13@gmail.com",
git_user_name="brencher_bot"
)
buildDocker = DockerComposeBuild(clone,
docker_repo_username="",
docker_repo_password="",
docker_compose_path="hermes_squid/stack-compose.yml",
docker_repo_url="https://registry.rudolf.keenetic.link",
publish=False,
build_cache = True,
envs=lambda: {
"version": "auto-" + checkoutMerged.progress().version,
# "user_group": "1000:137"
},
)
deployDocker = DockerSwarmDeploy(
wd=clone,
buildDocker=buildDocker,
stackChecker=dockerSwarmCheck,
envs=lambda: {
"version": "auto-" + checkoutMerged.progress().version,
},
stack_name="hermes_infra",
docker_compose_path="hermes_squid/stack-compose.yml",
)
# checkPing1 = UrlCheck(
# url="http://100.70.193.97:8088/api/status",
# expected=lambda obj: obj['gateway_running'] == 'true' and obj['auth_required'] == 'true',
# )
logUrls = SimpleLog(message={
"userLinks": {
"App": "https://hermes.rudolf.keenetic.link",
}
})
__all__ = ["hermes_infra"]
hermes_infra = Environment(
id="hermes_infra",
state=state,
pipeline=[
clone,
state,
checkoutMerged,
dockerSwarmCheck,
unmerge,
deployDocker,
# checkPing1,
logUrls
]
)
+5 -5
View File
@@ -31,10 +31,10 @@ deployDocker = DockerSwarmDeploy(
docker_compose_path="poc/immich/stack-compose.yml",
)
#checkPing = UrlCheck(
# url="https://immich.rudolf.keenetic.link/api/server/ping",
# expected={"res": "pong"},
#)
checkPing = UrlCheck(
url="https://immich.rudolf.keenetic.link/api/server/ping",
expected={"res": "pong"},
)
logUrls = SimpleLog(message={
"userLinks": {
"App": "https://immich.rudolf.keenetic.link",
@@ -52,7 +52,7 @@ immich = Environment(
dockerSwarmCheck,
unmerge,
deployDocker,
# checkPing,
checkPing,
logUrls
]
)
+3 -3
View File
@@ -99,7 +99,7 @@ class DockerComposeBuild(AbstractStep[Dict[str, str]]):
pass
logger.info(f"Building image {image} from {build_ctx}, {build_dockerfile}")
img, _ = client.images.build(path=build_ctx, dockerfile=build_dockerfile, tag=image, nocache=not self.build_cache, rm=True)
img, _ = client.images.build(path=build_ctx, dockerfile=build_dockerfile, tag=image, nocache=not self.build_cache, rm=not self.build_cache)
if self.publish:
logger.info(f"Pushing image {image}")
@@ -279,8 +279,8 @@ class DockerSwarmDeploy(AbstractStep[str]):
swarmEnv = {k: v for k, v in dotenv_values(os.path.join(os.path.dirname(tmp_compose_path), ".env")).items()
if v is not None}
# merge_dicts(swarmEnv, env)
result = subprocess.run(cmd, capture_output=True, text=True, cwd=os.path.dirname(tmp_compose_path))
#, env=swarmEnv)
result = subprocess.run(cmd, capture_output=True, text=True)
# , cwd=os.path.dirname(tmp_compose_path), env=swarmEnv)
os.remove(tmp_compose_path)
if result.returncode != 0:
logger.error(f"Stack deploy failed: {result.stderr}")
+7 -4
View File
@@ -119,6 +119,7 @@ class CheckoutMerged(AbstractStep[CheckoutAndMergeResult]):
desired_branches: AbstractStep[SharedState],
git_user_email: str,
git_user_name: str,
ignore_missing_branches: bool = True,
push: bool = True,
**kwargs: Any):
super().__init__(**kwargs)
@@ -127,7 +128,7 @@ class CheckoutMerged(AbstractStep[CheckoutAndMergeResult]):
self.git_user_email = git_user_email
self.git_user_name = git_user_name
self.push = push
self.ignore_missing_branches = ignore_missing_branches
def _find_merge_childs(self, tree: Dict[Commit, List[Commit]], commit: Commit) -> List[Commit]:
visited = [commit]
@@ -155,6 +156,8 @@ class CheckoutMerged(AbstractStep[CheckoutAndMergeResult]):
commit = repo.commit(desired_commit)
commit_ids[commit] = branch_name
except BaseException as e:
if not self.ignore_missing_branches:
raise e
stack = traceback.format_exception(type(e), e, e.__traceback__)
logger.error(f"Error finding desired commits for branch {branch_pair}: {str(e)}\n{''.join(stack)}")
return commit_ids
@@ -229,7 +232,7 @@ class CheckoutMerged(AbstractStep[CheckoutAndMergeResult]):
version = '-'.join([x.hexsha[0:8] for x in sorted_commits])
for ref in repo.refs:
if ref.is_remote() and ref.commit == repo.head.commit and ref.name != 'origin/HEAD':
if ref.is_remote() and ref.is_valid() and ref.commit == repo.head.commit and ref.name != 'origin/HEAD':
logger.info(f"Merge commit {ref.commit} corresponds to branch {ref}")
remote_branch_name = ref.name[len('origin/'):]
break
@@ -293,9 +296,9 @@ class GitUnmerge(AbstractStep[GitUnmergeResult]):
for v in version_parts:
commit = repo.commit(v)
# branches = [head.name for head in repo.heads if head.commit.hexsha == commit.hexsha]
branches = [ref.name for ref in repo.remotes.origin.refs if ref.commit.hexsha == commit.hexsha]
branches = [ref.name for ref in repo.remotes.origin.refs if not ref.name.startswith('origin/HEAD') and ref.commit.hexsha == commit.hexsha]
branches = [b[len('origin/'):] for b in branches if
b.startswith('origin/') and not b.startswith('origin/HEAD')]
b.startswith('origin/') ]
if len(branches) == 0 or branches[0].startswith('auto/'):
if childs is None:
+2 -5
View File
@@ -42,11 +42,8 @@ class SharedStateHolderInMemory(AbstractStep[SharedState], SharedStateHolder):
def progress(self) -> SharedState:
if len(self.state.branches) == 0:
if self.unmerge:
try:
unmerge = self.unmerge.progress()
self.state = replace(self.state, branches=unmerge.branches, token=uuid.uuid4().hex)
except BaseException as e:
logger.error("Unmerge failed: %s", e)
unmerge = self.unmerge.progress()
self.state = replace(self.state, branches=unmerge.branches, token=uuid.uuid4().hex)
return self.state
+7
View File
@@ -60,3 +60,10 @@ class CachingStep(AbstractStep[T], Generic[T]):
def __getattr__(self, name: str) -> Any:
"""Delegate unknown attributes to the wrapped step."""
return getattr(self._step, name)
def __setattr__(self, name: str, value: Any) -> None:
"""Delegate unknown attributes to the wrapped step."""
if name in {"name", "_step", "_result", "_input_hash"}:
super().__setattr__(name, value)
else:
setattr(self._step, name, value)
+1 -9
View File
@@ -129,7 +129,6 @@ class WebApp:
async def broadcast_environments(self, data: Any) -> None:
await self.broadcast("environments", data)
await self.broadcast("version", self.get_version())
async def broadcast_error(self, data: Any) -> None:
await self.broadcast("error", data)
@@ -141,16 +140,11 @@ class WebApp:
# --- Routes ---
def get_version(self) -> str:
return os.getenv('VERSION', 'unknown') or 'unknown'
async def serve_index(self) -> FileResponse:
return FileResponse(os.path.join(FRONTEND_DIR, 'index.html'))
async def serve_state(self) -> Response:
state = self.get_global_envs_to_emit()
state['version'] = self.get_version()
return Response(content=custom_json_dumps(state), media_type="application/json")
return Response(content=custom_json_dumps(self.get_global_envs_to_emit()), media_type="application/json")
async def serve_branches_route(self) -> Response:
return Response(content=custom_json_dumps(self.get_global_branches_to_emit()), media_type="application/json")
@@ -169,8 +163,6 @@ class WebApp:
# Send initial state on connect and record it so duplicate broadcasts are suppressed
branches_payload = custom_json_dumps({"branches": self.get_global_branches_to_emit()})
envs_payload = custom_json_dumps({"environments": self.get_global_envs_to_emit()})
version_payload = custom_json_dumps({"version": self.get_version()})
await websocket.send_text(version_payload)
await websocket.send_text(branches_payload)
self.ws_connections[websocket]["branches"] = branches_payload
await websocket.send_text(envs_payload)
+1 -2
View File
@@ -16,8 +16,7 @@ services:
- PYTHONUNBUFFERED=1
- VIRTUAL_HOST=brencher.rudolf.keenetic.link
- LETSENCRYPT_HOST=brencher.rudolf.keenetic.link
- VERSION=${version}
- PROFILES=brencher2,torrserv_proxy,immich,gmail_mcp,hermes,hermes_infra,gitea
- PROFILES=brencher2,torrserv_proxy,immich,registry,gmail_mcp,backupsHelper
- SECONDARY_BRENCHER=http://host.docker.internal:5002
deploy:
replicas: 1
-3
View File
@@ -13,7 +13,6 @@ const closeStatus = document.getElementById('close-status');
const refreshBranchesBtn = document.getElementById('refresh-branches');
const applyChangesBtn = document.getElementById('apply-changes');
const branchFilter = document.getElementById('branch-filter');
const appVersion = document.getElementById('app-version');
// Branches list (flattened) for UI rendering: [{ envId, envName, branch, commits: [] }]
let branches = [];
@@ -478,8 +477,6 @@ function setupWebSockets() {
filterBranches();
renderJobs();
showStatus('Environments updated.');
} else if ('version' in message) {
appVersion.textContent = `Version: ${message.version || 'unknown'}`;
} else if ('error' in message) {
console.error('Error from server:', message.error);
if (message.error && message.error.code === 'BRANCH_STATE_CONFLICT' && message.error.envId) {
-1
View File
@@ -10,7 +10,6 @@
<div class="container">
<header>
<h1>Brencher - Branch Merger</h1>
<p class="version" id="app-version">Version: loading...</p>
<div id="status-bar" class="status-bar hidden">
<span id="status-message"></span>
<button id="close-status">×</button>
-7
View File
@@ -15,13 +15,6 @@ body {
padding: 32px;
}
.version {
color: #6c757d;
font-family: monospace;
font-size: 0.85rem;
margin-top: -12px;
}
.primary-button {
background: #007bff;
color: #fff;
+61
View File
@@ -0,0 +1,61 @@
from git import BadName
import pytest
from enironment import get_step
from steps.git import CheckoutMerged
from tests.conftest import repo_helper
from .test_remote_repo import RemoteRepoHelper
class TestGitRemoveBranch:
"""Integration tests for git operations"""
def test_checkout_merged_one_branch(self, repo_helper: RemoteRepoHelper) -> None:
# Create main branch with initial commit
commit1 = repo_helper.create_commit(repo_helper.repo, "master", "master", "file1.txt", "content1",
"Initial commit") # noqa: F841
commit2 = repo_helper.create_commit(repo_helper.repo, "master", "branch1", "file2.txt", "content2",
"Branch1 commit") # noqa: F841
commit3 = repo_helper.create_commit(repo_helper.repo, "master", "branch2", "file3.txt", "content3",
"Branch2 commit") # noqa: F841
repo_helper.enable_caching()
repo_helper.set_desired_branches([("branch1", "HEAD"), ("branch2", "HEAD")])
repo_helper.progress()
repo_helper.verify_working_directory_files([
('file1.txt', 'content1'),
('file2.txt', 'content2'),
('file3.txt', 'content3'),
])
assert repo_helper.checkout_merged.progress().version == '-'.join([it[:8] for it in sorted([commit2.hexsha, commit3.hexsha])])
repo_helper.remove_branch(repo_helper.repo, "branch2")
# CheckoutMerged should raise an error when it can't find the branch, and ignore_missing_branches is False
get_step(repo_helper.env.pipeline, CheckoutMerged).ignore_missing_branches = False
with pytest.raises(BadName, match="Ref 'origin/branch2' did not resolve to an object"):
repo_helper.progress()
assert repo_helper.get_desired_branches() == [("branch1", "HEAD"), ("branch2", "HEAD")]
with pytest.raises(BadName, match="Ref 'origin/branch2' did not resolve to an object"):
repo_helper.checkout_merged.progress()
# Now set ignore_missing_branches to True and verify that it ignores the missing branch and continues processing
get_step(repo_helper.env.pipeline, CheckoutMerged).ignore_missing_branches = True
repo_helper.progress()
assert repo_helper.get_desired_branches() == [("branch1", "HEAD"), ("branch2", "HEAD")]
assert repo_helper.checkout_merged.progress().version == '-'.join([it[:8] for it in [commit2.hexsha]])
# Removing missing branch should be processed well
repo_helper.set_desired_branches([("branch1", "HEAD")])
repo_helper.progress()
assert repo_helper.checkout_merged.progress().version == '-'.join([it[:8] for it in [commit2.hexsha]])
repo_helper.verify_working_directory_files([
('file1.txt', 'content1'),
('file2.txt', 'content2'),
])
+27 -7
View File
@@ -10,8 +10,8 @@ import tempfile
from typing import Dict, Tuple, List, Callable, cast
import git
from enironment import Environment, AbstractStep, SharedStateHolder, get_step
from enironment import Environment, AbstractStep, wrap_in_cached, get_step, SharedStateHolder
from processing import reset_caches
from steps.docker import DockerSwarmCheckResult
from steps.git import CheckoutAndMergeResult, CheckoutMerged, GitUnmerge, GitClone, HasVersion, GitUnmergeResult
from steps.shared_state import SharedStateHolderInMemory
@@ -106,6 +106,22 @@ class RemoteRepoHelper:
def mock_check(self) -> AbstractStep[Dict[str, HasVersion]]:
return get_step(self.env.pipeline, MockDockerSwarmCheck)
def enable_caching(self) -> None:
"""Wrap environment pipeline in caching steps"""
self.env = wrap_in_cached(self.env)
def progress(self) -> None:
reset_caches([self.env])
for i in self.env.pipeline:
i.progress()
def remove_branch(self, repo: git.Repo, branch_name: str) -> None:
"""Remove a branch from the repository"""
if branch_name in [head.name for head in repo.heads]:
repo.delete_head(branch_name, force=True)
else:
raise BaseException(f"Branch doesn't exist {branch_name}.")
def teardown(self) -> None:
"""Clean up temporary directories"""
if self.remote_dir:
@@ -142,7 +158,9 @@ class RemoteRepoHelper:
with open(file_path, 'w') as f:
f.write(content)
repo.index.add([filename])
return repo.index.commit(message)
result = repo.index.commit(message)
repo.git.checkout(result.hexsha, detach=True)
return result
def verify_working_directory_files(self, expected_files: List[Tuple[str, str]]) -> None:
"""Verify that working directory contains exactly the expected files with correct content.
@@ -168,10 +186,12 @@ class RemoteRepoHelper:
repo = git.Repo(repo_path)
commits = list(repo.iter_commits("--all", max_count=30))
refs = [
f"{_as_text(it.commit)[:10]}:{_as_text(it.name)}, is_remote:{it.is_remote()}"
for it in repo.refs
]
refs = []
for it in repo.references:
try:
refs.append(f"{_as_text(it.commit)[:10]}:{_as_text(it.name)}, is_remote:{it.is_remote()}")
except Exception as e:
refs.append(f"Error reading branch {it.name}: {e}")
lines = [
f"{_as_text(commit.hexsha)[:10]} (p{[_as_text(it.hexsha)[:10] for it in commit.parents]}): {_as_text(commit.message).splitlines()[0]}"
for commit in commits