File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,12 @@ Lets print the latest version of `<local_dir> dir1/file2.txt`
168168
169169Previous version of `<local_dir>/dir1/file2.txt `
170170
171+ .. literalinclude :: ../../test/test_quick_doc.py
172+ :language: python
173+ :dedent: 8
174+ :start-after: # [18.1-test_cloned_repo_object]
175+ :end-before: # ![18.1-test_cloned_repo_object]
176+
171177* $ git status
172178
173179 * Untracked files
Original file line number Diff line number Diff line change @@ -177,21 +177,24 @@ def print_files_from_git(root, level=0):
177177 # Output <git.Blob "SHA1-HEX-HASH-1">
178178 # ![17-test_cloned_repo_object]
179179
180- # print pre
181- # [17.1-test_cloned_repo_object]
182- commits_for_file = [c for c in repo .iter_commits (all = True , paths = print_file )]
183- blob = tree [print_file ]
184-
185- # ![17.1-test_cloned_repo_object]
186-
180+ # print latest file
187181 # [18-test_cloned_repo_object]
188182 blob = tree [print_file ]
189183 print (blob .data_stream .read ().decode ())
190184
191185 # Output
192186 # file 2 version 1
193187 # Update version 2
194-
195188 # ![18-test_cloned_repo_object]
196189
190+ # print previous tree
191+ # [18.1-test_cloned_repo_object]
192+ commits_for_file = [c for c in repo .iter_commits (all = True , paths = print_file )]
193+ tree = commits_for_file [- 1 ].tree # gets the first commit tree
194+ blob = tree [print_file ]
195+
196+ print (blob .data_stream .read ().decode ())
197197
198+ # Output
199+ # file 2 version 1
200+ # ![18.1-test_cloned_repo_object]
You can’t perform that action at this time.
0 commit comments