Close Fileclose
@@ -3084,6 +3096,25 @@ INDEX = Template(r"""
}
}
+ function gitstash() {
+ var path = document.getElementById("fbheader").innerHTML;
+ if (path.length > 0) {
+ data = new Object();
+ data.path = path;
+ $.post("api/stash", data).done(function(resp) {
+ if (resp.error) {
+ var $toastContent = $("
" + resp.message + "\n" + resp.path + "
");
+ Materialize.toast($toastContent, 5000);
+ }
+ else {
+ var $toastContent = $("
");
+ Materialize.toast($toastContent, 5000);
+ listdir(document.getElementById('fbheader').innerHTML);
+ }
+ });
+ }
+ }
+
function checkout(branch) {
var path = document.getElementById("fbheader").innerHTML;
if (path.length > 0) {
@@ -4197,6 +4228,38 @@ class RequestHandler(BaseHTTPRequestHandler):
LOG.warning("Exception (no repo): %s" % str(err))
else:
response['message'] = "Missing path or branch"
+ elif req.path.endswith('/api/stash'):
+ try:
+ postvars = parse_qs(self.rfile.read(length).decode('utf-8'), keep_blank_values=1)
+ except Exception as err:
+ LOG.warning(err)
+ response['message'] = "%s" % (str(err))
+ postvars = {}
+ if 'path' in postvars.keys():
+ if postvars['path']:
+ try:
+ repopath = unquote(postvars['path'][0])
+ response['path'] = repopath
+ try:
+ repo = REPO(repopath)
+ returnvalue = repo.git.stash()
+ response['error'] = False
+ response['message'] = "%s\n%s" % (returnvalue, repopath)
+ self.send_response(200)
+ self.send_header('Content-type', 'text/json')
+ self.end_headers()
+ self.wfile.write(bytes(json.dumps(response), "utf8"))
+ return
+ except Exception as err:
+ response['error'] = True
+ response['message'] = str(err)
+ LOG.warning(response)
+
+ except Exception as err:
+ response['message'] = "Not a git repository: %s" % (str(err))
+ LOG.warning("Exception (no repo): %s" % str(err))
+ else:
+ response['message'] = "Missing path or branch"
elif req.path.endswith('/api/newfolder'):
try:
postvars = parse_qs(self.rfile.read(length).decode('utf-8'), keep_blank_values=1)
diff --git a/dev.html b/dev.html
index 9885afc..3121431 100644
--- a/dev.html
+++ b/dev.html
@@ -607,11 +607,13 @@
git init
git commit
git push
+
git stash
+
+
+
git stash
+
Are you sure you want to stash your changes?
+
+
+
Close Fileclose
@@ -2992,6 +3004,25 @@
}
}
+ function gitstash() {
+ var path = document.getElementById("fbheader").innerHTML;
+ if (path.length > 0) {
+ data = new Object();
+ data.path = path;
+ $.post("api/stash", data).done(function(resp) {
+ if (resp.error) {
+ var $toastContent = $("
" + resp.message + "\n" + resp.path + "
");
+ Materialize.toast($toastContent, 5000);
+ }
+ else {
+ var $toastContent = $("
");
+ Materialize.toast($toastContent, 5000);
+ listdir(document.getElementById('fbheader').innerHTML);
+ }
+ });
+ }
+ }
+
function checkout(branch) {
var path = document.getElementById("fbheader").innerHTML;
if (path.length > 0) {