Git
Git helper functions.
ChangeType
Bases: Enum
Git change kinds, retaining the original public enum values.
Source code in databooks/git_utils.py
21 22 23 24 25 26 27 28 29 30 | |
ConflictFile
dataclass
Container for path and different versions of conflicted notebooks.
Source code in databooks/git_utils.py
41 42 43 44 45 46 47 48 49 | |
Contents
dataclass
Container for path of file versions.
Source code in databooks/git_utils.py
52 53 54 55 56 57 | |
DiffContents
dataclass
Container for path and different versions of conflicted notebooks.
Source code in databooks/git_utils.py
60 61 62 63 64 65 66 | |
UnmergedBlob
dataclass
Container for git unmerged blobs.
Source code in databooks/git_utils.py
33 34 35 36 37 38 | |
blob2commit(blob, repo)
Get the short commit message from blob hash.
Source code in databooks/git_utils.py
82 83 84 85 86 87 88 89 90 | |
blob2str(blob)
blob2str(blob: None) -> None
blob2str(blob: Blob) -> bytes
Get the blob contents if they exist (otherwise return None).
Source code in databooks/git_utils.py
77 78 79 | |
diff2contents(blob, ref, path, not_exists=False)
Get the blob contents from the diff.
Depends on whether we are diffing against current working tree and if object exists
at diff time (added or deleted objects only exist at one side). If comparing
against working tree (ref=None) we return the current file contents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blob
|
Blob
|
git diff blob |
required |
ref
|
Optional[Union[IndexFile, Tree, Commit, str]]
|
git reference |
required |
path
|
Path
|
path to object |
required |
not_exists
|
bool
|
whether object exists at 'diff time' (added or removed objects do not exist) |
False
|
Returns:
| Type | Description |
|---|---|
Optional[str | bytes]
|
blob contents as a string (if exists) |
Source code in databooks/git_utils.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
get_conflict_blobs(repo)
Get the source files for conflicts.
Source code in databooks/git_utils.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
get_nb_diffs(ref_base=None, ref_remote=None, paths=(), *, repo=None, verbose=False)
Get the noteebook(s) git diff(s).
By default, diffs are compared with the current working directory. That is, staged files will still show up in the diffs. Only return the diffs for notebook files.
Source code in databooks/git_utils.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
get_repo(path)
Find git repo in current or parent directories.
Source code in databooks/git_utils.py
120 121 122 123 124 125 126 127 128 | |