3b9e66f00fdd7d72ec134c1ffebc90e14349fc2e
commit 3b9e66f00fdd7d72ec134c1ffebc90e14349fc2e
Author: spesk1 <spesk@pm.me>
Date: Sat Jun 22 20:45:44 2019 +0000

Display configured clone interface

diff --git a/README.md b/README.md
index 7ef4471..aaa8139 100644
--- a/README.md
+++ b/README.md
@@ -15,9 +15,10 @@ DONE:
* Extremely basic markdown parser (only supports headings and non nested bullets
* Line numbers for file browsing
* Diff highlighting for log
+* Show git:// address for cloning (configurable via config file)

TODO:
-* Show git:// address for cloning (configurable via config file)
+* Get diff stat for top of log index links
* Code needs to be more robust / handle failure cases
* Need to recurse git home, right now will only pull dirs in root of git home
* README.md markdown renderer/parser / display in project index
diff --git a/config.default b/config.default
index 433c00b..25f5391 100644
--- a/config.default
+++ b/config.default
@@ -1,3 +1,5 @@
-GitHome = "/home/git"
+GitHome = "/home/git/"
WebRoot = "/var/www/html/git"
+CloneEnabled = "yes"
+ClonePath = "git://site.xz:/"
IgnoredProjects = [ "/home/git/projec_to_ignore.git/", "/home/git/some_project_to_ignore2.git/" ]
diff --git a/gsg b/gsg
index 1703f3a..1add206 100755
--- a/gsg
+++ b/gsg
@@ -73,6 +73,8 @@ sub dump_config {
}
}

+dump_config();
+
# Get projects list
my $git_projects_ref = get_projects($config{'GitHome'},$config{'IgnoredProjects'},$logger);
foreach my $p ( @$git_projects_ref ) {
@@ -89,6 +91,13 @@ my $trimmed_git_projects_ref = trim_project_paths($git_projects_ref,$logger);
write_root_index($root_index,$trimmed_git_projects_ref,$web_projects_dir,$logger);

# Write project contents
-write_project_content($git_projects_ref,$trimmed_git_projects_ref,$web_projects_dir,$logger);
+my $clone_path;
+if ( $config{'CloneEnabled'} eq "yes" ) {
+ $clone_path = $config{'ClonePath'};
+} else {
+ $clone_path = "Disabled";
+}
+
+write_project_content($git_projects_ref,$trimmed_git_projects_ref,$web_projects_dir,$clone_path,$logger);

$logger->info("Done");
diff --git a/lib/Gsg/Gather.pm b/lib/Gsg/Gather.pm
index 850f8a8..3917e27 100644
--- a/lib/Gsg/Gather.pm
+++ b/lib/Gsg/Gather.pm
@@ -4,7 +4,22 @@ use warnings;
use Log::Log4perl qw(:easy);
use Shellex::Shellex qw(shellex findBin);
use Exporter qw(import);
-our @EXPORT_OK = qw(get_file_tree get_projects trim_project_paths);
+our @EXPORT_OK = qw(get_file_tree get_projects trim_project_paths get_diff_stat);
+
+sub get_diff_stat($$$$) {
+
+ my $project_dir = shift;
+ my $newest_commit = shift;
+ my $compare_commit = shift;
+ my $logger = shift;
+
+ # git --git-dir=/home/git/git-site-gen.git/ diff --stat 37f54811d49d41a4d794594e5bbaaee2271d82ad 1afd193eda9a6bc703011a72afa273e560355713
+ my $gitCmd = findBin("git",$logger);
+ my $diff_stat = shellex("$gitCmd --git-dir=$project_dir $newest_commit $compare_commit",$logger);
+
+ return $diff_stat;
+
+}

sub get_projects($$$) {

diff --git a/lib/Gsg/Html.pm b/lib/Gsg/Html.pm
index 0ab52a0..c1896d1 100644
--- a/lib/Gsg/Html.pm
+++ b/lib/Gsg/Html.pm
@@ -4,7 +4,7 @@ use warnings;
use Log::Log4perl qw(:easy);
use lib "/usr/local/lib";
use Shellex::Shellex qw(shellex findBin);
-use Gsg::Gather qw(get_file_tree);
+use Gsg::Gather qw(get_file_tree get_diff_stat);
use Gsg::MdParse qw (render_readme);
use Exporter qw(import);
our @EXPORT_OK = qw(
@@ -155,11 +155,12 @@ sub gen_diff_colors($$$) {

# Main sub for generating project page
# Might make more sense to split into more subs?
-sub write_project_content($$$$) {
+sub write_project_content($$$$$) {

my $project_dirs_ref = shift;
my $trimmed_project_dirs_ref = shift;
my $web_projects_dir = shift;
+ my $clone_path = shift;
my $logger = shift;

# Make these array's easier to work with in a hash
@@ -173,7 +174,12 @@ sub write_project_content($$$$) {
my $spec_web_dir = $web_projects_dir . $projects_map{$project_path};
my $project_index = $spec_web_dir . "index.html";
write_file("",$project_index);
- append_file("<html><a href=\"../../index.html\">Return to index</a></b><hr/>",$project_index);
+ append_file("<html><a href=\"../../index.html\"><b>Return to index</a></b></br>",$project_index);
+ my $uniq_clone_path = "Disabled";
+ if ( $clone_path ne "Disabled" ) {
+ $uniq_clone_path = $clone_path . $projects_map{$project_path};
+ }
+ append_file("<b><pre>Clone:<font color=\"green\"> git clone $uniq_clone_path</font></pre></b><hr/>",$project_index);
# Get all project data structures/info
my ( $file_tree_ref, $file_content_ref, $commits_ref, $commit_ids_ref ) = get_file_tree($project_path,$logger);