Skip to content

Commit 3df2040

Browse files
committed
Show commit hash in IDE
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]>
1 parent ace7bd7 commit 3df2040

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Diff for: .travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ before_script:
77
- git clone https://github.com/felix-lang/fbuild.git
88
script:
99
- fbuild/fbuild-light && build/tst
10+
- git describe --tags --always >> version.txt
1011
addons:
1112
apt:
1213
packages:
@@ -15,6 +16,7 @@ deploy:
1516
provider: heroku
1617
api_key:
1718
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=
19+
skip_cleanup: true
1820
app: o-lang
1921
on:
2022
repo: phase/o

Diff for: ide.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
#!/usr/bin/env python
22
# NOTE: pass -d to this to print debugging info when the server crashes.
33
from flask import Flask, render_template, url_for, request
4-
from subprocess import Popen, PIPE, check_call
4+
from subprocess import Popen, PIPE, check_call, check_output
55
import sys, os, string, glob, logging, pathlib
66

77
app = Flask(__name__)
88

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

12+
# Git commit hash for easy version checking
13+
version = ""
14+
if os.path.isfile("version.txt"):
15+
with open("version.txt", "r") as f:
16+
version = f.readline().strip()
17+
else:
18+
version = check_output(["git", "describe", "--tags", "--always"]).decode("utf-8")
19+
1220
def compileO():
1321
r = check_call(['make', 'ide'])
1422
print("o-ide: " + "".join(glob.glob("oide*")))
@@ -38,12 +46,12 @@ def index():
3846
#Output to IDE
3947
if p.returncode:
4048
print('Output:', output, 'error:', error)
41-
return render_template('error.html', code=code, input=input, error=error)
49+
return render_template('error.html', version=version, code=code, input=input, error=error)
4250
else:
4351
print('Output:', output, 'stack:', error)
44-
return render_template('code.html', code=code, input=input, output=output, stack=error or '[]')
52+
return render_template('code.html', version=version, code=code, input=input, output=output, stack=error or '[]')
4553
else:
46-
return render_template('primary.html')
54+
return render_template('primary.html', version=version)
4755

4856
@app.route('/link/')
4957
@app.route('/link/<code>/')

Diff for: templates/primary.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<div class="col-xs-6">
1212
<h1><a href="https://github.com/phase/o">O</a> Language IDE</h1>
1313
<p>You can find documentation for the O Programming Language at <a href="https://o.readthedocs.org">o.readthedocs.org</a>.
14-
The GitHub repository is located at <a href="https://github.com/phase/o">github.com/phase/o</a>.</p>
14+
The GitHub repository is located at <a href="https://github.com/phase/o">github.com/phase/o</a>.<br/><br/>
15+
Current Version: <b>{{ version }}</b>
16+
</p>
1517
<br/>
1618
<p id="byteCount">0 bytes and 0 chars long.</p>
1719
<p>Code</p>

0 commit comments

Comments
 (0)