adding repo syncing

This commit is contained in:
Andrew Davidson 2012-04-22 01:04:40 -07:00
parent 9527898ef4
commit f8b9b6f96c

View file

@ -180,6 +180,7 @@ def upload(path=''):
@route('/upload', method="POST")
def do_upload():
repo = Repo(conf['repo'])
repo.git.pull()
path = request.forms.path
@ -216,8 +217,7 @@ def do_upload():
repo.git.add(new_file)
content.append("<p>Git: ")
commit_result = repo.git.commit(new_file,m=message)
if not commit_result.endswith('.'):
commit_result += '.'
repo.git.push()
content.append(commit_result)
content.append('</p>')
else:
@ -271,10 +271,13 @@ def delete():
message = request.forms.message
result = False
repo.git.pull()
if os.path.exists(os.path.join(conf['repo'],path)):
try:
repo.git.rm(path, r=True)
result = repo.git.commit(path, m=" '"+re.sub("'","\\'",message)+"'")
repo.git.push()
except:
if not isdir(os.path.join(conf['repo'],path)):
os.remove(os.path.join(conf['repo'],path))
@ -351,6 +354,8 @@ def edit():
message = request.forms.message
full_path = os.path.join(conf['repo'],path)
repo.git.pull()
body = []
f = open(full_path, 'w')
@ -362,6 +367,8 @@ def edit():
commit = repo.git.commit(path,m=message)
repo.git.push()
body.append('<p><a href="/repo/'+path+'">' + path + '</a> edited.</p>')
body.append('<p>Git: ' + commit + '</p>')
@ -414,6 +421,8 @@ def new():
message = request.forms.message
full_path = os.path.join(conf['repo'], directory, filename)
repo.git.pull()
w = open(full_path, 'w')
w.write(content)
w.close()
@ -431,6 +440,8 @@ def new():
repo.git.add(os.path.join(directory, filename))
commit = repo.git.commit(os.path.join(directory, filename),m=message)
repo.git.push()
body = []
body.append('<p>'+filename+' added to <a href="/repo/'+directory+'">'+(directory if not directory == '' else '/')+'</a></p>')
if commit:
@ -485,10 +496,14 @@ def rename():
if not os.path.exists(new):
repo = Repo(conf['repo'])
repo.git.pull()
repo.git.mv(current,new)
if not message: message = datetime.now().isoformat()
commit = repo.git.commit(current,new,m=message)
repo.git.push()
body.append('<p>'+request.forms.current+' moved to '\
+request.forms.destination+'.</p>')
body.append('<p>Git: '+commit+'</p>')