orchestr8.directory_tracker
A Git-based directory tracker that provides version control functionality.
This class wraps Git commands to provide simple version control capabilities, including tracking changes, committing modifications, and undoing uncommitted changes. Supports large files through Git LFS when directory size exceeds a configurable limit.
# Initialize tracker for a specific directory
tracker = DirectoryTracker(
path="path/to/directory",
use_lfs_after_size=200 # Use Git LFS if directory size exceeds 200MB
)
# Check if directory is being tracked
print(tracker.is_tracking)
# Check for changes
print(tracker.has_changes)
# Commit all changes
tracker.commit("Updated files")
# Undo all uncommited changes if needed
tracker.undo()
# Delete the .git directory
tracker.delete()
# Initialize tracking explicitly
tracker.initialize()
Source code in orchestr8/directory_tracker.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
has_changes: bool
property
¶
Check if there are any uncommitted changes in the tracked directory.
Returns:
Type | Description |
---|---|
bool
|
True if there are uncommitted changes, False otherwise |
Raises:
Type | Description |
---|---|
LookupError
|
If |
is_lfs_required: bool
property
¶
Check if the directory requires Git LFS.
Returns:
Type | Description |
---|---|
bool
|
True if the directory size exceeds the configured limit, False otherwise |
is_tracking: bool
property
¶
Check if git tracking is enabled for the directory.
Returns:
Type | Description |
---|---|
bool
|
True if the directory is being tracked (has .git directory), False otherwise |
is_using_lfs: bool
property
¶
Check if the repository is using Git LFS.
Returns:
Type | Description |
---|---|
bool
|
True if Git LFS is configured and initialized, False otherwise |
Raises:
Type | Description |
---|---|
LookupError
|
If |
path: Path
property
¶
The directory path.
shell: Shell
property
¶
The shell instance.
commit
¶
Commit all changes made to the tracked directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__message
|
str
|
The commit message |
required |
empty
|
bool
|
If True, create a commit even if there are no changes |
False
|
bypass
|
bool
|
If True, bypass pre-commit and commit-msg hooks |
False
|
Raises:
Type | Description |
---|---|
LookupError
|
If |
Source code in orchestr8/directory_tracker.py
delete
¶
Delete the .git directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
commit
|
bool
|
Whether to commit all changes before deleting |
True
|
Raises:
Type | Description |
---|---|
LookupError
|
If |
Source code in orchestr8/directory_tracker.py
initialize
¶
Initialize tracking directory changes.
Source code in orchestr8/directory_tracker.py
raise_if_not_tracking
¶
Raise LookUpError if the directory is not being tracked.
undo
¶
Undo all uncommitted changes in the tracked directory.
This operation: 1. Removes untracked files and directories 2. Resets all tracked files to their last committed state
Raises:
Type | Description |
---|---|
LookupError
|
If |