-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature:RainbowGrades] Display RainbowGrades version (#56)
This update allows all users of RainbowGrades (i.e. instructors and students) to see the build version at the bottom of the RainbowGrades page. This version info is vital as it allows instructors to know which version they are currently using. Having this version information readily available will enable instructors to provide accurate details when reporting any issues or errors they encounter. In turn, developers can use this version information to identify any potential discrepancies caused by outdated versions and assist instructors more efficiently in resolving their concerns. [Instructor view] ![Screen Shot 2023-07-28 at 11 49 10 AM](https://github.com/Submitty/RainbowGrades/assets/123261952/81ce995a-0086-4ead-9f0b-0d3686017d77) [student view] ![Screen Shot 2023-07-28 at 1 39 52 PM](https://github.com/Submitty/RainbowGrades/assets/123261952/0776a2e8-6f9d-4567-bf6a-e38c6142300f) --------- Co-authored-by: William Powe <[email protected]> Co-authored-by: Barb Cutler <[email protected]> Co-authored-by: Barb Cutler <Barb Cutler>
- Loading branch information
1 parent
d2a0118
commit f911fe0
Showing
4 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import json | ||
import subprocess | ||
|
||
CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) | ||
RG_DIR = os.environ.get('RAINBOW_GRADES_DIRECTORY') | ||
REPORT_DIR = os.environ.get('REPORTS_DIRECTORY') | ||
WORKING_DIRECTORY = "." | ||
|
||
if __name__ == "__main__": | ||
|
||
json_dir = os.path.join(WORKING_DIRECTORY, "RG_version.json") | ||
output_dict = {} | ||
current_commit_hash_rg = 'unknown' | ||
current_short_commit_hash_rg = 'unknown' | ||
current_git_tag_rg = 'unknown' | ||
|
||
try: | ||
#run the command 'git rev-parse HEAD' from the RainbowGrades repository directory | ||
current_commit_hash_rg = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=RG_DIR) | ||
current_commit_hash_rg = current_commit_hash_rg.decode('ascii').strip() | ||
current_short_commit_hash_rg = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=RG_DIR) | ||
current_short_commit_hash_rg = current_short_commit_hash_rg.decode('ascii').strip() | ||
print("Commit {0} is currently installed on this system.".format(current_commit_hash_rg)) | ||
except: | ||
print("ERROR: could not determine commit hash.") | ||
current_commit_hash_rg = 'unknown' | ||
|
||
try: | ||
#run the command 'git describe --tag --abbrev=0' from the RainbowGrades repository directory | ||
current_git_tag_rg = subprocess.check_output(['git', 'describe', '--tag', '--abbrev=0'], cwd=RG_DIR) | ||
current_git_tag_rg = current_git_tag_rg.decode('ascii').strip() | ||
print("Tag {0} is the most recent git tag.".format(current_git_tag_rg)) | ||
except: | ||
print("ERROR: could not determine current git tag.") | ||
current_git_tag_rg = 'unknown' | ||
|
||
|
||
#remove newline at the end of the hash and tag and convert them from bytes to ascii. | ||
|
||
output_dict["installed_commit_rg"] = current_commit_hash_rg | ||
output_dict["short_installed_commit_rg"] = current_short_commit_hash_rg | ||
output_dict["most_recent_git_tag_rg"] = current_git_tag_rg | ||
|
||
|
||
try: | ||
#Update rainbow_grades/RG_version.json to reflect the current commit hash. | ||
with open(json_dir, 'w') as outfile: | ||
json.dump(output_dict, outfile, indent=2) | ||
except: | ||
print("ERROR: could not write to {0}".format(json_dir)) |