diff options
| author | 2020-02-03 23:00:53 +0000 | |
|---|---|---|
| committer | 2020-02-03 23:00:53 +0000 | |
| commit | 7a15e5b2bf314093d6ce36ae56832a793712113a (patch) | |
| tree | 7722676b96e6b2a7043478849a1757d48bb94a2e /modules | |
| parent | actually return gitlab _note result (diff) | |
| signature | ||
store timestamp and current git commit when loading a module
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/info.py | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/modules/info.py b/modules/info.py index 6674e39f..8b9ad9e6 100644 --- a/modules/info.py +++ b/modules/info.py @@ -4,23 +4,11 @@ from src import IRCBot, ModuleManager, utils class Module(ModuleManager.BaseModule): @utils.hook("received.command.version") def version(self, event): - commit_hash = None - git_dir = os.path.join(self.bot.directory, ".git") - head_filepath = os.path.join(git_dir, "HEAD") - if os.path.isfile(head_filepath): - ref = None - with open(head_filepath, "r") as head_file: - ref = head_file.readline().split(" ", 1)[1].strip() - branch = ref.rsplit("/", 1)[1] - - ref_filepath = os.path.join(git_dir, ref) - if os.path.isfile(ref_filepath): - with open(ref_filepath, "r") as ref_file: - commit_hash = ref_file.readline().strip() + commit_hash = utils.git_commit(self.bot.directory) out = "Version: BitBot %s" % IRCBot.VERSION if not commit_hash == None: - out = "%s (%s@%s)" % (out, branch, commit_hash[:8]) + out = "%s (%s@%s)" % (out, branch, commit_hash) event["stdout"].write(out) @utils.hook("received.command.source") |
