Skip to content

Commit 5a46298

Browse files
authored
feat: require sync (#66)
This is a prerequisite to improving the conflict/merge flow. Also refactor to omit the `gitpython` dependency.
1 parent f8d0b32 commit 5a46298

File tree

12 files changed

+250
-200
lines changed

12 files changed

+250
-200
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ pipx install git-draft[openai]
2424
* Mechanism for reporting feedback from a bot, and possibly allowing user to
2525
interactively respond.
2626
* Add MCP bot.
27+
* Store configuration in `gitconfig` as `draft.*` entries. This can be used for
28+
example to set a unique repo ID, and default bot to use per repo (or more
29+
widely via shared `gitconfig` files).

docs/git-draft.adoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ IMPORTANT: `git-draft` is WIP.
1919

2020
[verse]
2121
git draft [options] [--generate] [--accept... | --no-accept] [--bot BOT]
22-
[--edit] [--reset | --no-reset] [--sync | --no-sync]
23-
[TEMPLATE [VARIABLE...]]
24-
git draft [options] --finalize [--delete] [--sync | --no-sync]
22+
[--edit] [--reset | --no-reset] [TEMPLATE [VARIABLE...]]
23+
git draft [options] --finalize [--delete]
2524
git draft [options] --show-drafts [--json]
2625
git draft [options] --show-prompts [--json] [PROMPT]
2726
git draft [options] --show-templates [--json | [--edit] TEMPLATE]
@@ -96,11 +95,6 @@ git draft [options] --show-templates [--json | [--edit] TEMPLATE]
9695
Lists available templates.
9796
With an template name argument, displays the corresponding template's contents or, if the `--edit` option is set, opens an interactive editor.
9897

99-
-s::
100-
--sync::
101-
--no-sync::
102-
Create a sync commit with any changes.
103-
10498
-t TIMEOUT::
10599
--timeout=TIMEOUT::
106100
Action timeout.

poetry.lock

Lines changed: 2 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ readme = "README.md"
77
dynamic = ["version"]
88
requires-python = ">=3.12"
99
dependencies = [
10-
"gitpython (>=3.1.44,<4)",
1110
"jinja2 (>=3.1.5,<4)",
1211
"prettytable (>=3.15.1,<4)",
1312
"xdg-base-dirs (>=6.0.2,<7)",

src/git_draft/__main__.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ def callback(
9494
help="use JSON for table output",
9595
action="store_true",
9696
)
97-
parser.add_option(
98-
"-s",
99-
"--sync",
100-
help="commit prior worktree changes separately",
101-
action="store_true",
102-
)
10397

10498
parser.add_option(
10599
"--no-accept",
@@ -114,12 +108,6 @@ def callback(
114108
dest="reset",
115109
action="store_false",
116110
)
117-
parser.add_option(
118-
"--no-sync",
119-
help="do not commit intermediate worktree changes",
120-
dest="sync",
121-
action="store_false",
122-
)
123111
parser.add_option(
124112
"--reset",
125113
help="reset index before generating a new draft",
@@ -160,7 +148,7 @@ def on_rename_file(
160148
self,
161149
src_path: PurePosixPath,
162150
dst_path: PurePosixPath,
163-
_reason: str | None
151+
_reason: str | None,
164152
) -> None:
165153
print(f"Renamed {src_path} to {dst_path}.")
166154

@@ -233,7 +221,6 @@ def main() -> None: # noqa: PLR0912 PLR0915
233221
prompt_transform=open_editor if editable else None,
234222
tool_visitors=[ToolPrinter()],
235223
reset=config.reset if opts.reset is None else opts.reset,
236-
sync=config.sync if opts.sync is None else opts.sync,
237224
)
238225
match accept:
239226
case Accept.MANUAL:
@@ -245,10 +232,7 @@ def main() -> None: # noqa: PLR0912 PLR0915
245232
case _:
246233
raise UnreachableError()
247234
case "finalize":
248-
draft = drafter.finalize_draft(
249-
delete=opts.delete,
250-
sync=config.sync if opts.sync is None else opts.sync,
251-
)
235+
draft = drafter.finalize_draft(delete=opts.delete)
252236
print(f"Finalized {draft.branch_name}.")
253237
case "show-drafts":
254238
table = drafter.history_table(args[0] if args else None)

src/git_draft/common.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Config:
4242
bots: Sequence[BotConfig] = dataclasses.field(default_factory=lambda: [])
4343
log_level: int = logging.INFO
4444
reset: bool = True
45-
sync: bool = False
4645

4746
@staticmethod
4847
def folder_path() -> Path:
@@ -74,6 +73,17 @@ class BotConfig:
7473
pythonpath: str | None = None
7574

7675

76+
type RepoID = str
77+
78+
79+
@dataclasses.dataclass(frozen=True)
80+
class RepoConfig: # TODO: Use
81+
"""Repository-specific config"""
82+
83+
repo_id: str
84+
bot_name: str | None = None
85+
86+
7787
def config_string(arg: str) -> str:
7888
"""Dereferences environment value if the input starts with `$`"""
7989
return os.environ[arg[1:]] if arg and arg.startswith("$") else arg

0 commit comments

Comments
 (0)