Added basic git stash functionality (Issue #16)
This commit is contained in:
parent
c24654418b
commit
8502faee6e
3 changed files with 95 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
Version 0.3.0 (2018-)
|
Version 0.3.0 (2018-)
|
||||||
- Allow passing settings (except lists) via environment variables (Issue #100) @danielperna84
|
- Allow passing settings (except lists) via environment variables (Issue #100) @danielperna84
|
||||||
|
- Added basic git stash functionality (Issue #16) @danielperna84
|
||||||
|
|
||||||
Version 0.2.9 (2018-06-22)
|
Version 0.2.9 (2018-06-22)
|
||||||
- Material Icons and HASS-help now open in new tab instead of modal (Issues #85 and #34) @danielperna84
|
- Material Icons and HASS-help now open in new tab instead of modal (Issues #85 and #34) @danielperna84
|
||||||
|
|
|
@ -699,11 +699,13 @@ INDEX = Template(r"""<!DOCTYPE html>
|
||||||
<li><a class="modal-trigger" href="#modal_init" class="nowrap waves-effect">git init</a></li>
|
<li><a class="modal-trigger" href="#modal_init" class="nowrap waves-effect">git init</a></li>
|
||||||
<li><a class="modal-trigger" href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
<li><a class="modal-trigger" href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
||||||
<li><a class="modal-trigger" href="#modal_push" class="nowrap waves-effect">git push</a></li>
|
<li><a class="modal-trigger" href="#modal_push" class="nowrap waves-effect">git push</a></li>
|
||||||
|
<li><a class="modal-trigger" href="#modal_stash" class="nowrap waves-effect">git stash</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul id="dropdown_gitmenu_mobile" class="dropdown-content z-depth-4">
|
<ul id="dropdown_gitmenu_mobile" class="dropdown-content z-depth-4">
|
||||||
<li><a class="modal-trigger" href="#modal_init" class="nowrap waves-effect">git init</a></li>
|
<li><a class="modal-trigger" href="#modal_init" class="nowrap waves-effect">git init</a></li>
|
||||||
<li><a class="modal-trigger" href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
<li><a class="modal-trigger" href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
||||||
<li><a class="modal-trigger" href="#modal_push" class="nowrap waves-effect">git push</a></li>
|
<li><a class="modal-trigger" href="#modal_push" class="nowrap waves-effect">git push</a></li>
|
||||||
|
<li><a class="modal-trigger" href="#modal_stash" class="nowrap waves-effect">git stash</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="modal_acekeyboard" class="modal bottom-sheet modal-fixed-footer">
|
<div id="modal_acekeyboard" class="modal bottom-sheet modal-fixed-footer">
|
||||||
<div class="modal-content centered">
|
<div class="modal-content centered">
|
||||||
|
@ -1311,6 +1313,16 @@ INDEX = Template(r"""<!DOCTYPE html>
|
||||||
<a onclick="gitpush()" class=" modal-action modal-close waves-effect waves-green btn-flat light-blue-text">OK</a>
|
<a onclick="gitpush()" class=" modal-action modal-close waves-effect waves-green btn-flat light-blue-text">OK</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="modal_stash" class="modal">
|
||||||
|
<div class="modal-content">
|
||||||
|
<h4 class="grey-text text-darken-3">git stash<i class="mdi mdi-git right grey-text text-darken-3" style="font-size: 2.48rem;"></i></h4>
|
||||||
|
<p>Are you sure you want to stash your changes?</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a class=" modal-action modal-close waves-effect waves-red btn-flat light-blue-text">Cancel</a>
|
||||||
|
<a onclick="gitstash()" class=" modal-action modal-close waves-effect waves-green btn-flat light-blue-text">OK</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="modal_close" class="modal">
|
<div id="modal_close" class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h4 class="grey-text text-darken-3">Close File<i class="grey-text text-darken-3 material-icons right" style="font-size: 2.28rem;">close</i></h4>
|
<h4 class="grey-text text-darken-3">Close File<i class="grey-text text-darken-3 material-icons right" style="font-size: 2.28rem;">close</i></h4>
|
||||||
|
@ -3084,6 +3096,25 @@ INDEX = Template(r"""<!DOCTYPE html>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = $("<div><pre>" + resp.message + "\n" + resp.path + "</pre></div>");
|
||||||
|
Materialize.toast($toastContent, 5000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var $toastContent = $("<div><pre>" + resp.message + "</pre></div>");
|
||||||
|
Materialize.toast($toastContent, 5000);
|
||||||
|
listdir(document.getElementById('fbheader').innerHTML);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkout(branch) {
|
function checkout(branch) {
|
||||||
var path = document.getElementById("fbheader").innerHTML;
|
var path = document.getElementById("fbheader").innerHTML;
|
||||||
if (path.length > 0) {
|
if (path.length > 0) {
|
||||||
|
@ -4197,6 +4228,38 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||||
LOG.warning("Exception (no repo): %s" % str(err))
|
LOG.warning("Exception (no repo): %s" % str(err))
|
||||||
else:
|
else:
|
||||||
response['message'] = "Missing path or branch"
|
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'):
|
elif req.path.endswith('/api/newfolder'):
|
||||||
try:
|
try:
|
||||||
postvars = parse_qs(self.rfile.read(length).decode('utf-8'), keep_blank_values=1)
|
postvars = parse_qs(self.rfile.read(length).decode('utf-8'), keep_blank_values=1)
|
||||||
|
|
31
dev.html
31
dev.html
|
@ -607,11 +607,13 @@
|
||||||
<li><a class="modal-trigger" href="#modal_init" class="nowrap waves-effect">git init</a></li>
|
<li><a class="modal-trigger" href="#modal_init" class="nowrap waves-effect">git init</a></li>
|
||||||
<li><a class="modal-trigger" href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
<li><a class="modal-trigger" href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
||||||
<li><a class="modal-trigger" href="#modal_push" class="nowrap waves-effect">git push</a></li>
|
<li><a class="modal-trigger" href="#modal_push" class="nowrap waves-effect">git push</a></li>
|
||||||
|
<li><a class="modal-trigger" href="#modal_stash" class="nowrap waves-effect">git stash</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul id="dropdown_gitmenu_mobile" class="dropdown-content z-depth-4">
|
<ul id="dropdown_gitmenu_mobile" class="dropdown-content z-depth-4">
|
||||||
<li><a class="modal-trigger" href="#modal_init" class="nowrap waves-effect">git init</a></li>
|
<li><a class="modal-trigger" href="#modal_init" class="nowrap waves-effect">git init</a></li>
|
||||||
<li><a class="modal-trigger" href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
<li><a class="modal-trigger" href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
||||||
<li><a class="modal-trigger" href="#modal_push" class="nowrap waves-effect">git push</a></li>
|
<li><a class="modal-trigger" href="#modal_push" class="nowrap waves-effect">git push</a></li>
|
||||||
|
<li><a class="modal-trigger" href="#modal_stash" class="nowrap waves-effect">git stash</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="modal_acekeyboard" class="modal bottom-sheet modal-fixed-footer">
|
<div id="modal_acekeyboard" class="modal bottom-sheet modal-fixed-footer">
|
||||||
<div class="modal-content centered">
|
<div class="modal-content centered">
|
||||||
|
@ -1219,6 +1221,16 @@
|
||||||
<a onclick="gitpush()" class=" modal-action modal-close waves-effect waves-green btn-flat light-blue-text">OK</a>
|
<a onclick="gitpush()" class=" modal-action modal-close waves-effect waves-green btn-flat light-blue-text">OK</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="modal_stash" class="modal">
|
||||||
|
<div class="modal-content">
|
||||||
|
<h4 class="grey-text text-darken-3">git stash<i class="mdi mdi-git right grey-text text-darken-3" style="font-size: 2.48rem;"></i></h4>
|
||||||
|
<p>Are you sure you want to stash your changes?</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a class=" modal-action modal-close waves-effect waves-red btn-flat light-blue-text">Cancel</a>
|
||||||
|
<a onclick="gitstash()" class=" modal-action modal-close waves-effect waves-green btn-flat light-blue-text">OK</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="modal_close" class="modal">
|
<div id="modal_close" class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h4 class="grey-text text-darken-3">Close File<i class="grey-text text-darken-3 material-icons right" style="font-size: 2.28rem;">close</i></h4>
|
<h4 class="grey-text text-darken-3">Close File<i class="grey-text text-darken-3 material-icons right" style="font-size: 2.28rem;">close</i></h4>
|
||||||
|
@ -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 = $("<div><pre>" + resp.message + "\n" + resp.path + "</pre></div>");
|
||||||
|
Materialize.toast($toastContent, 5000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var $toastContent = $("<div><pre>" + resp.message + "</pre></div>");
|
||||||
|
Materialize.toast($toastContent, 5000);
|
||||||
|
listdir(document.getElementById('fbheader').innerHTML);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkout(branch) {
|
function checkout(branch) {
|
||||||
var path = document.getElementById("fbheader").innerHTML;
|
var path = document.getElementById("fbheader").innerHTML;
|
||||||
if (path.length > 0) {
|
if (path.length > 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue