Skip to content

Commit 2f177c8

Browse files
authored
feat: keep track of repo root (#28)
1 parent 86e9771 commit 2f177c8

File tree

8 files changed

+12
-13
lines changed

8 files changed

+12
-13
lines changed

src/git_draft/bots/openai.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ def act(self, prompt: str, toolbox: Toolbox) -> Action:
109109
)
110110
thread = self._client.beta.threads.create()
111111

112-
message = self._client.beta.threads.messages.create(
112+
self._client.beta.threads.messages.create(
113113
thread_id=thread.id,
114114
role="user",
115115
content=prompt,
116116
)
117-
print(message)
118117

119118
with self._client.beta.threads.runs.stream(
120119
thread_id=thread.id,

src/git_draft/manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def _create_branch(self, sync: bool) -> _Branch:
124124
sql("add-branch"),
125125
{
126126
"suffix": suffix,
127+
"repo_path": self._repo.working_dir,
127128
"origin_branch": origin_branch,
128129
"origin_sha": origin_sha,
129130
"sync_sha": sync_sha,

src/git_draft/prompts/update-imports.jinja

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
insert into branches (suffix, origin_branch, origin_sha, sync_sha)
2-
values (:suffix, :origin_branch, :origin_sha, :sync_sha);
1+
insert into branches (suffix, repo_path, origin_branch, origin_sha, sync_sha)
2+
values (:suffix, :repo_path, :origin_branch, :origin_sha, :sync_sha);

src/git_draft/queries/create-tables.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
create table if not exists branches (
22
suffix text primary key,
3+
repo_path text not null,
34
created_at timestamp default current_timestamp,
45
origin_branch text not null,
56
origin_sha text not null,

src/git_draft/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class Store:
17-
_name = "db.v1.sqlite3"
17+
_name = "v1.sqlite3"
1818

1919
def __init__(self, conn: sqlite3.Connection) -> None:
2020
self._connection = conn

tests/git_draft/common_test.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
import git_draft.common as sut
77

88

9-
@pytest.fixture(autouse=True)
10-
def state_home(monkeypatch, tmp_path) -> None:
11-
path = tmp_path / "state"
12-
monkeypatch.setenv("XDG_STATE_HOME", str(path))
13-
14-
159
def test_ensure_state_home() -> None:
1610
path = sut.ensure_state_home()
1711
assert path.exists()

tests/git_draft/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ def repo(tmp_path: Path) -> Iterator[git.Repo]:
99
repo = git.Repo.init(str(tmp_path / "repo"), initial_branch="main")
1010
repo.index.commit("init")
1111
yield repo
12+
13+
14+
@pytest.fixture(autouse=True)
15+
def state_home(monkeypatch, tmp_path) -> None:
16+
path = tmp_path / "state"
17+
monkeypatch.setenv("XDG_STATE_HOME", str(path))

0 commit comments

Comments
 (0)