From 56752dbb0a1837c6004bc38aae09d0b0542fe9a9 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Sun, 27 Apr 2008 19:59:00 +0000 Subject: [PATCH] git-ftp-sync: Track mirror state in a remote branch. If one update fails, it will be included in the next updates." darcs-hash:20080427195900-f2ef6-95da2d4e784cd27ee38316452e210d813f045134.gz --- git-ftp-sync | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/git-ftp-sync b/git-ftp-sync index 2425b7f..cf5cf11 100755 --- a/git-ftp-sync +++ b/git-ftp-sync @@ -233,6 +233,13 @@ def selftest(): print print "Selftest succeeded!" +def update_ref(hash): + remote = "ftp" + branch = "master" + if (not os.path.exists("refs/remotes/"+remote)): + os.makedirs("refs/remotes/"+remote) + file("refs/remotes/"+remote+"/"+branch, "w").write(newrev+"\n") + def build_change_list(changes, oldrev, newrev): # Read changes gitdiff = Popen("/usr/bin/git diff --name-status %s %s"%(oldrev, newrev), @@ -264,6 +271,10 @@ changes = list() for line in sys.stdin: (oldrev, newrev, refname) = line.split() if refname == "refs/heads/master": + try: + oldref=file("refs/remotes/ftp/master").readline().strip(); + except IOError: + pass build_change_list(changes, oldrev, newrev) if not changes: @@ -283,7 +294,9 @@ try: syncer.close() except ftplib.all_errors, detail: - print >> sys.stderr, "FTP error: ", detail + print >> sys.stderr, "FTP synchronization error: ", detail + print >> sys.stderr, "I will try it next time again" sys.exit(1) - - + +# If succeessfull, update remote ref +update_ref(newrev) -- 2.39.2