MCPcopy Index your code
hub / github.com/PyQt5/PyQtClient / CloneThread

Class CloneThread

Utils/GitThread.py:154–276  ·  view source on GitHub ↗

获取项目源码

Source from the content-addressed store, hash-verified

152
153
154class CloneThread(QObject):
155 """获取项目源码
156 """
157
158 Url = 'git://github.com/PyQt5/PyQt.git'
159
160 @classmethod
161 def quit(cls):
162 """退出线程
163 :param cls:
164 """
165 if hasattr(cls, '_thread'):
166 cls._thread.quit()
167 AppLog.info('clone thread quit')
168
169 @classmethod
170 def start(cls, parent=None):
171 """启动Clone线程
172 :param cls:
173 """
174 cls._thread = QThread(parent)
175 cls._worker = CloneThread()
176 cls._worker.moveToThread(cls._thread)
177 cls._thread.started.connect(cls._worker.run)
178 cls._thread.finished.connect(cls._worker.deleteLater)
179 cls._thread.start()
180 AppLog.info('clone thread started')
181
182 def pull(self, repo, remote_name='origin', branch='master'):
183 """ pull changes for the specified remote (defaults to origin).
184
185 Code from MichaelBoselowitz at:
186 https://github.com/MichaelBoselowitz/pygit2-examples/blob/
187 68e889e50a592d30ab4105a2e7b9f28fac7324c8/examples.py#L58
188 licensed under the MIT license.
189 """
190 for remote in repo.remotes:
191 if remote.name == remote_name:
192 remote.fetch()
193 remote_master_id = repo.lookup_reference(
194 'refs/remotes/origin/%s' % (branch)).target
195 merge_result, _ = repo.merge_analysis(remote_master_id)
196 # Up to date, do nothing
197 if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE:
198 return
199 # We can just fastforward
200 elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD:
201 repo.checkout_tree(repo.get(remote_master_id))
202 try:
203 master_ref = repo.lookup_reference('refs/heads/%s' %
204 (branch))
205 master_ref.set_target(remote_master_id)
206 except KeyError:
207 repo.create_branch(branch, repo.get(remote_master_id))
208 repo.head.set_target(remote_master_id)
209 elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL:
210 repo.merge(remote_master_id)
211

Callers 1

startMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected