Skip to content

Commit

Permalink
Show commit hash in IDE
Browse files Browse the repository at this point in the history
The IDE will show the version it is running.

This value is the output of
    git describe --tags

Heroku doesn't keep the git repository data, so we need to cache the
result during the Travis build for Heroku to use.

Signed-off-by: Jadon Fowler <[email protected]>
  • Loading branch information
phase committed Jul 12, 2016
1 parent ace7bd7 commit 3df2040
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ before_script:
- git clone https://github.com/felix-lang/fbuild.git
script:
- fbuild/fbuild-light && build/tst
- git describe --tags --always >> version.txt
addons:
apt:
packages:
Expand All @@ -15,6 +16,7 @@ deploy:
provider: heroku
api_key:
secure: ClCKc4/UPxDD4nU07VAJs8NudDfOKEw76PLCqINwQAESdbEybOeSDQqMTxSXpK2q/M1kiKRVj/oNh9Pyi//MX9Jvne2pSaK1gpsinOncQ7sKbHhECcWPYGHhv6xoOal0A0Tpl2fhzlYoeQk85/rGo7fB3dAbud5EtNj7As64eT/7zNoRsBmofTL2+Ltdvq+Jrso/6j78+Z42lHN4RTKpb2p+7uFCs83QPFmRxVDUVtxMx09AnOp6F86uUo1KrJeTkVy/RTgB/4NTag2uoydonxZ4bj+FfelQPJ4iOzHM4mT9UAfJ4OEpAh+oYnDhP4OBiXiUT66cs5/BsFKCYxT32fMf1OXiOz6FT0GNx4JLe89isN41wS0hz7+fwFOGNonhQPuwEFWe6//ZfqZqDsAHavGkLUMd/PZ37/EJOVKOVR9Rxa0TFglQIaBucUNn1+hUjjLJBnnV9DeBtVTgqNqHs5g4PeqhdCti/LGCV7YSGyDTZMAZphmacrKU91Bf6q9lTeLWBbLF2ob4TnqXSFZbeNE5kysoh5yqyQW6Ey0qG3Quqau27OXs9A2pPwoSakpGLVDLjfBmvZRwjAlC1SlvCqqGsmuxDhQT4gkE2F9na6gtogLE0VNgr1vK20FhOIKFg3cvie8A8Z903k64SIJuU/iv6OpNrxGutFiqDvTDGQE=
skip_cleanup: true
app: o-lang
on:
repo: phase/o
16 changes: 12 additions & 4 deletions ide.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#!/usr/bin/env python
# NOTE: pass -d to this to print debugging info when the server crashes.
from flask import Flask, render_template, url_for, request
from subprocess import Popen, PIPE, check_call
from subprocess import Popen, PIPE, check_call, check_output
import sys, os, string, glob, logging, pathlib

app = Flask(__name__)

app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)

# Git commit hash for easy version checking
version = ""
if os.path.isfile("version.txt"):
with open("version.txt", "r") as f:
version = f.readline().strip()
else:
version = check_output(["git", "describe", "--tags", "--always"]).decode("utf-8")

def compileO():
r = check_call(['make', 'ide'])
print("o-ide: " + "".join(glob.glob("oide*")))
Expand Down Expand Up @@ -38,12 +46,12 @@ def index():
#Output to IDE
if p.returncode:
print('Output:', output, 'error:', error)
return render_template('error.html', code=code, input=input, error=error)
return render_template('error.html', version=version, code=code, input=input, error=error)
else:
print('Output:', output, 'stack:', error)
return render_template('code.html', code=code, input=input, output=output, stack=error or '[]')
return render_template('code.html', version=version, code=code, input=input, output=output, stack=error or '[]')
else:
return render_template('primary.html')
return render_template('primary.html', version=version)

@app.route('/link/')
@app.route('/link/<code>/')
Expand Down
4 changes: 3 additions & 1 deletion templates/primary.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
<div class="col-xs-6">
<h1><a href="https://github.com/phase/o">O</a> Language IDE</h1>
<p>You can find documentation for the O Programming Language at <a href="https://o.readthedocs.org">o.readthedocs.org</a>.
The GitHub repository is located at <a href="https://github.com/phase/o">github.com/phase/o</a>.</p>
The GitHub repository is located at <a href="https://github.com/phase/o">github.com/phase/o</a>.<br/><br/>
Current Version: <b>{{ version }}</b>
</p>
<br/>
<p id="byteCount">0 bytes and 0 chars long.</p>
<p>Code</p>
Expand Down

0 comments on commit 3df2040

Please sign in to comment.