Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbccf8bc

Browse files
committed
added new section for diffs and formatting
1 parent315405d commitbccf8bc

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

‎doc/source/quickstart.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,30 @@ Status
216216
:start-after: # [11-test_cloned_repo_object]
217217
:end-before: # ![11-test_cloned_repo_object]
218218

219+
Diffs
220+
######
221+
222+
Compare staging area to head commit
223+
224+
..literalinclude::../../test/test_quick_doc.py
225+
:language: python
226+
:dedent: 8
227+
:start-after: # [11.1-test_cloned_repo_object]
228+
:end-before: # ![11.1-test_cloned_repo_object]
229+
230+
..literalinclude::../../test/test_quick_doc.py
231+
:language: python
232+
:dedent: 8
233+
:start-after: # [11.2-test_cloned_repo_object]
234+
:end-before: # ![11.2-test_cloned_repo_object]
235+
236+
Compare commit to commit
237+
238+
..literalinclude::../../test/test_quick_doc.py
239+
:language: python
240+
:dedent: 8
241+
:start-after: # [11.3-test_cloned_repo_object]
242+
:end-before: # ![11.3-test_cloned_repo_object]
219243

220244

221245

‎test/test_quick_doc.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_init_repo_object(self, path_to_dir):
1919

2020
fromgitimportRepo
2121

22-
repo=Repo.init(path_to_dir)# git init path/to/dir
22+
repo=Repo.init(path_to_dir)
2323
# ![1-test_init_repo_object]
2424

2525
# [2-test_init_repo_object]
@@ -111,10 +111,43 @@ def test_cloned_repo_object(self, local_dir):
111111
fordindiffs:
112112
print(d.a_path)
113113

114+
# Output
114115
# Downloads/file3.txt
115-
# file4.txt
116116
# ![11-test_cloned_repo_object]
117117

118+
# compares staging area to head commit
119+
# [11.1-test_cloned_repo_object]
120+
diffs=repo.index.diff(repo.head.commit)
121+
fordindiffs:
122+
print(d.a_path)
123+
124+
# Output
125+
126+
# ![11.1-test_cloned_repo_object]
127+
# [11.2-test_cloned_repo_object]
128+
# lets add untracked.txt
129+
repo.index.add(['untracked.txt'])
130+
diffs=repo.index.diff(repo.head.commit)
131+
fordindiffs:
132+
print(d.a_path)
133+
134+
# Output
135+
# untracked.txt
136+
# ![11.2-test_cloned_repo_object]
137+
138+
# Compare commit to commit
139+
# [11.3-test_cloned_repo_object]
140+
first_commit= [cforcinrepo.iter_commits(all=True)][-1]
141+
diffs=repo.head.commit.diff(first_commit)
142+
fordindiffs:
143+
print(d.a_path)
144+
145+
# Output
146+
# dir1/file2.txt
147+
# ![11.3-test_cloned_repo_object]
148+
149+
150+
118151
'''Trees and Blobs'''
119152

120153
# Latest commit tree
@@ -141,7 +174,7 @@ def test_cloned_repo_object(self, local_dir):
141174
# ![14-test_cloned_repo_object]
142175

143176
# [14.1-test_cloned_repo_object]
144-
files_and_dirs= [(entry,entry.name)forentryintree]
177+
files_and_dirs= [(entry,entry.name,entry.type)forentryintree]
145178
files_and_dirs
146179

147180
# Output

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp