8000 docs(git): from_rev_and_commit docstring · commitizen-tools/commitizen@ee06b43 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee06b43

Browse files
bearomorphismLee-W
authored andcommitted
docs(git): from_rev_and_commit docstring
1 parent 169d30b commit ee06b43

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

commitizen/git.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,48 @@ def message(self):
4343

4444
@classmethod
4545
def from_rev_and_commit(cls, rev_and_commit: str) -> GitCommit:
46+
"""Create a GitCommit instance from a formatted commit string.
47+
48+
This method parses a multi-line string containing commit information in the following format:
49+
```
50+
<rev>
51+
<parents>
52+
<title>
53+
<author>
54+
<author_email>
55+
<body_line_1>
56+
<body_line_2>
57+
...
58+
```
59+
60+
Args:
61+
rev_and_commit (str): A string containing commit information with fields separated by newlines.
62+
- rev: The commit hash/revision
63+
- parents: Space-separated list of parent commit hashes
64+
- title: The commit title/message
65+
- author: The commit author's name
66+
- author_email: The commit author's email
67+
- body: Optional multi-line commit body
68+
69+
Returns:
70+
GitCommit: A new GitCommit instance with the parsed information.
71+
72+
Example:
73+
>>> commit_str = '''abc123
74+
... def456 ghi789
75+
... feat: add new feature
76+
... John Doe
77+
... john@example.com
78+
... This is a detailed description
79+
... of the new feature'''
80+
>>> commit = GitCommit.from_rev_and_commit(commit_str)
81+
>>> commit.rev
82+
'abc123'
83+
>>> commit.title
84+
'feat: add new feature'
85+
>>> commit.parents
86+
['def456', 'ghi789']
87+
"""
4688
rev, parents, title, author, author_email, *body_list = rev_and_commit.split(
4789
"\n"
4890
)

0 commit comments

Comments
 (0)
0