aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranon2025-08-17 15:12:07 +0200
committeranon2025-08-17 15:12:07 +0200
commitcd2b1f4b2fa38a5c76c22401897bb2a7be5d7da7 (patch)
tree48e45b614bc037ecee4baebc5e0313cf654b5026
parentbb90c030df92787343d710ce96e126119270febf (diff)
downloadgorillanest-cd2b1f4b2fa38a5c76c22401897bb2a7be5d7da7.tar.xz
gorillanest-cd2b1f4b2fa38a5c76c22401897bb2a7be5d7da7.tar.zst
something vaguely representing what we need
-rwxr-xr-xgit-construct.pl57
1 files changed, 57 insertions, 0 deletions
diff --git a/git-construct.pl b/git-construct.pl
new file mode 100755
index 0000000..5e97088
--- /dev/null
+++ b/git-construct.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Git::Repository;
+use Cwd 'realpath';
+use File::Basename;
+
+use Data::Dumper;
+
+sub new_repository {
+ my ($path) = @_;
+ $path = realpath($path);
+
+ my $name = basename($path);
+ my $repo = Git::Repository->new(work_tree => $path);
+
+ my @raw_branches = $repo->run('branch');
+ my @branches;
+
+ for my $b (@raw_branches) {
+ chomp $b;
+ my $is_active = 0;
+
+ if ($b =~ /^\* /) {
+ $b =~ s/^\* //;
+ $is_active = 1;
+ }
+
+ my @commits;
+ my @logs = $repo->run(log => $b, '--pretty=format:%H;%an;%s');
+ for my $line (@logs) {
+ my ($hash, $author, $message) = split /;/, $line, 3;
+ push @commits, {
+ hash => $hash,
+ author => $author,
+ message => $message,
+ };
+ }
+
+ push @branches, {
+ name => $b,
+ is_active => $is_active,
+ commits => \@commits,
+ };
+ }
+
+ my $owner = $repo->run('log', '--reverse', '--pretty=format:%an');
+
+ return {
+ name => $name,
+ owner => $owner,
+ branches => \@branches,
+ };
+}
+
+print Dumper( new_repository('./') );