MCPcopy
hub / github.com/commitizen-tools/commitizen / create_file_and_commit

Method create_file_and_commit

tests/utils.py:47–64  ·  view source on GitHub ↗

Create a file and commit it.

(
        self,
        message: str,
        filename: str | None = None,
        committer_date: str | None = None,
    )

Source from the content-addressed store, hash-verified

45 self.patch_env()
46
47 def create_file_and_commit(
48 self,
49 message: str,
50 filename: str | None = None,
51 committer_date: str | None = None,
52 ) -> None:
53 """Create a file and commit it."""
54 if not filename:
55 filename = str(uuid.uuid4())
56
57 Path(filename).touch()
58 c = cmd.run(["git", "add", "."])
59 if c.return_code != 0:
60 raise exceptions.CommitError(c.err)
61 c = git.commit(message, committer_date=committer_date)
62 if c.return_code != 0:
63 raise exceptions.CommitError(c.err)
64 self.tick()
65
66 def create_branch(self, name: str) -> None:
67 """Create a new branch."""

Calls 1

tickMethod · 0.95