]> rtime.felk.cvut.cz Git - git-ftp-sync.git/blobdiff - git-ftp-sync
git-ftp-sync: Fixed typo
[git-ftp-sync.git] / git-ftp-sync
index 5d40c9da5d2ca3e3ac86c2fcb199a5f524b6220d..921c1c7e8163d1287580cd667275597119f3dc8b 100755 (executable)
@@ -135,14 +135,14 @@ class FTPSync(Syncer):
             # FIXME: this should be recursive deletion
             self.ftp.rmd(path)
         except ftplib.error_perm, detail:
-            print >> sys.stderr, "FTP warning:", detail
+            print >> sys.stderr, "FTP warning:", detail, path
 
     def _delete(self, path):
         try:
             #print >> sys.stderr, path
             self.ftp.delete(path)
         except ftplib.error_perm, detail:
-            print >> sys.stderr, "FTP warning:", detail, self.dest_path
+            print >> sys.stderr, "FTP warning:", detail, path
 
 
 class LocalSync(Syncer):
@@ -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:
+            oldrev=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)