wip: add commit-info command

This commit is contained in:
2021-04-26 00:23:14 +01:00
parent 9c977a75b5
commit 8d165b627b
10 changed files with 178 additions and 54 deletions

View File

@@ -1,14 +1,27 @@
# frozen_string_literal: true
require 'json'
require 'time'
require 'yaml'
require_relative './errors'
require_relative './common'
class Commit
include Common
attr_reader :repo
attr_reader :ref
attr_reader :message
attr_reader :sha
attr_reader :time
def initialize(sha:, time:)
def initialize(sha:, time:, repo: nil, ref: nil, message: nil)
@sha = sha
@time = time
@repo = repo
@ref = ref
@message = message
end
def sha_short
@@ -17,9 +30,13 @@ class Commit
def to_hash
{
'repo' => repo,
'ref' => ref,
'sha' => sha,
'sha_short' => sha_short,
'time' => time
'time' => time.utc,
'timestamp' => time.utc.to_i,
'message' => message
}
end