+def branchesForCommit(files):
+ branches = set()
+
+ for file in files:
+ relativePath = file["path"][len(prefix):]
+ # strip off the filename
+ relativePath = relativePath[0:relativePath.rfind("/")]
+
+ if len(branches) == 0:
+ branches.add(relativePath)
+ continue
+
+ ###### this needs more testing :)
+ knownBranch = False
+ for branch in branches:
+ if relativePath == branch:
+ knownBranch = True
+ break
+ if relativePath.startswith(branch):
+ knownBranch = True
+ break
+ if branch.startswith(relativePath):
+ branches.remove(branch)
+ break
+
+ if not knownBranch:
+ branches.add(relativePath)
+
+ return branches
+
+def commit(details, files, branch, prefix):