File tree 2 files changed +17
-8
lines changed
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`
168
168
169
169
Previous version of `<local_dir>/dir1/file2.txt `
170
170
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
+
171
177
* $ git status
172
178
173
179
* Untracked files
Original file line number Diff line number Diff line change @@ -177,21 +177,24 @@ def print_files_from_git(root, level=0):
177
177
# Output <git.Blob "SHA1-HEX-HASH-1">
178
178
# ![17-test_cloned_repo_object]
179
179
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
187
181
# [18-test_cloned_repo_object]
188
182
blob = tree [print_file ]
189
183
print (blob .data_stream .read ().decode ())
190
184
191
185
# Output
192
186
# file 2 version 1
193
187
# Update version 2
194
-
195
188
# ![18-test_cloned_repo_object]
196
189
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 ())
197
197
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