# frozen_string_literal: true require_relative "../base" module Neetob class CLI module Users class Commits < Base attr_accessor :sandbox, :apps, :author, :duration def initialize(author, duration, apps = ["*"], sandbox = false) super() @sandbox = sandbox @apps = apps @author = author @duration = duration end def run table_rows = build_commit_rows html_content = build_html_content(table_rows) create_html_file(html_content) open_html_file_in_default_system_application end private def build_commit_rows find_all_matching_apps(apps, :github, sandbox, true).map do |app| commits = commits_within_range(app) if commits.empty? ui.error("No commits found in \"#{app}\" for the given author and duration.") next end build_table_rows(app, commits) end end def commits_within_range(app) `git -C ./#{app_name_without_org_suffix(app)} log --pretty=format:"%H:::%ae:::%ar:::%s" --author=#{author} --since=#{duration} --no-merges` end def build_table_rows(app, commits) commits.split("\n").map { |commit| html_table_row(app, *commit.split(":::")) } end def app_name_without_org_suffix(app) app.split("/")[1] end def html_table_row(app, commit, email, time, title) starting_7_characters_of_commit = commit[0..6] "
Commit | Product | Created at | Title | |
---|---|---|---|---|
No commits found in the given duration |