Commit 436daa2
committed
[GitRepository] Add #git_transaction method
And also defines the following private helper methods and constants:
- `LOCKFILE_DIR` # Where the locks are stored
- `#git_lock_filename` # name of the lockfile for this record
- `#acquire_git_lock` # fetches a lock for the instance (one per)
- `#release_git_lock` # releases existing lock for other processes
`#git_transaction` is meant to be a multi-purpose method for dealing
with any file system changes so that only one process is able to
interact with it at a time. According to the docs (`ri File#flock`),
`File#flock(FILE::LOCK_EX)` should block until the lock is available for
the process, so the first process to acquire the lock will process
first.
The method is also designed so that nested `#git_transaction` calls will
no-op and not release the lock pre-maturely. This is important for
running multiple actions that by design need to happen by a single
process, but the sub actions are also configured to use the lock.
Implementation of this method will be done in a followup commit, but the
method is also meant to be a public interface so that when existing
methods implement this method, locks will work just fine with user
defined `git_transaction` blocks as well as with GitRepository method
API.1 parent f136c1a commit 436daa2
1 file changed
+51
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
89 | 110 | | |
90 | 111 | | |
91 | 112 | | |
| |||
155 | 176 | | |
156 | 177 | | |
157 | 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 | + | |
158 | 209 | | |
159 | 210 | | |
160 | 211 | | |
| |||
0 commit comments