mirror of
https://github.com/chubin/cheat.sh.git
synced 2026-06-20 13:16:44 +02:00
fetch/update works now
This commit is contained in:
@@ -145,6 +145,7 @@ class GitRepositoryAdapter(RepositoryAdapter): #pylint: disable=abstract-meth
|
||||
|
||||
local_repository_dir = cls.local_repository_location()
|
||||
state_filename = os.path.join(local_repository_dir, '.cached_revision')
|
||||
state = None
|
||||
if os.path.exists(state_filename):
|
||||
state = open(state_filename, 'r').read()
|
||||
return state
|
||||
|
||||
+6
-2
@@ -88,6 +88,7 @@ def _update_adapter(adptr):
|
||||
|
||||
If `adptr` returns no update_command(), it is being ignored.
|
||||
"""
|
||||
os.chdir(adptr.local_repository_location())
|
||||
|
||||
cmd = adptr.update_command()
|
||||
if not cmd:
|
||||
@@ -117,12 +118,13 @@ def _update_adapter(adptr):
|
||||
if cmd:
|
||||
errorcode, output = _run_cmd(cmd)
|
||||
if errorcode:
|
||||
_log("\nERROR:\n---\n" + output + "\n---\nCould not pages to be updated: %s" % adptr)
|
||||
_log("\nERROR:\n---\n" + output + "\n---\nCould not get list of pages to be updated: %s" % adptr)
|
||||
return False
|
||||
updates = output.splitlines()
|
||||
|
||||
entries = adptr.get_updates_list(updates)
|
||||
for entry in entries:
|
||||
print "ivalidating ", entry
|
||||
cache.delete(entry)
|
||||
|
||||
adptr.save_state(state)
|
||||
@@ -173,8 +175,10 @@ def main(args):
|
||||
_show_usage()
|
||||
sys.exit(0)
|
||||
|
||||
if args[0] == 'fetch':
|
||||
if args[0] == 'fetch-all':
|
||||
fetch_all()
|
||||
elif args[0] == 'update':
|
||||
update_by_name(sys.argv[1])
|
||||
elif args[0] == 'update-all':
|
||||
update_all()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user