-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathistorage.py
162 lines (134 loc) · 4.64 KB
/
istorage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
from zope.interface import Interface
class IStorageManager(Interface):
def active_branch(self):
"""
Return the name of the currently active branch
"""
def write_config(section, data):
"""
Write a config block for a git repository.
:param str section:
The section to write the data for.
:param dict data:
The keys & values of data to write
"""
def read_config(section):
"""
Read a config block for a git repository.
:param str section:
The section to read.
:returns: dict
"""
def storage_exists():
"""
Check if the storage exists. Returns ``True`` if the directory
exists, it does not check if it is an actual :py:class:`git.Repo`.
:returns: bool
"""
def destroy_storage():
"""
Destroy the repository's working dir.
"""
def iterate(model_class):
"""
This loads all known instances of this model from Git
because we need to know how to re-populate Elasticsearch.
:param elasticgit.models.Model model_class:
The class to look for instances of.
:returns: generator
"""
def get(model_class, uuid):
"""
Get a model instance by loading the data from git and constructing
the model_class
:param elasticgit.models.Model model_class:
The model class of which an instance to return
:param str uuid:
The uuid for the object to retrieve
:returns:
:py:class:elasticgit.models.Model
"""
def store(model, message, author=None, committer=None):
"""
Store an instance's data in Git.
:param elasticgit.models.Model model:
The model instance
:param str message:
The commit message.
:param tuple author:
The author information (name, email address)
Defaults repo default if unspecified.
:param tuple committer:
The committer information (name, email address).
Defaults to the author if unspecified.
:returns:
The commit.
"""
def store_data(repo_path, data, message,
author=None, committer=None):
"""
Store some data in a file
:param str repo_path:
Where to store the file.
:param obj data:
The data to write in the file.
:param str message:
The commit message.
:param tuple author:
The author information (name, email address)
Defaults repo default if unspecified.
:param tuple committer:
The committer information (name, email address).
Defaults to the author if unspecified.
:returns:
The commit
"""
def delete(model, message, author=None, committer=None):
"""
Delete a model instance from Git.
:param elasticgit.models.Model model:
The model instance
:param str message:
The commit message.
:param tuple author:
The author information (name, email address)
Defaults repo default if unspecified.
:param tuple committer:
The committer information (name, email address).
Defaults to the author if unspecified.
:returns:
The commit.
"""
def delete_data(repo_path, message,
author=None, committer=None):
"""
Delete a file that's not necessarily a model file.
:param str repo_path:
Which file to delete.
:param str message:
The commit message.
:param tuple author:
The author information (name, email address)
Defaults repo default if unspecified.
:param tuple committer:
The committer information (name, email address).
Defaults to the author if unspecified.
:returns:
The commit
"""
def pull(branch_name='master', remote_name='origin'):
"""
Fetch & Merge in an upstream's commits.
:param str branch_name:
The name of the branch to fast forward & merge in
:param str remote_name:
The name of the remote to fetch from.
"""
def path_info(path):
"""
Analyze a file path and return the object's class and the uuid.
:param str file_path:
The path of the object we want a model instance for.
:returns:
(model_class, uuid) tuple or ``None`` if not a model file path.
"""