aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/gittab
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/gittab')
-rwxr-xr-x.local/bin/gittab87
1 files changed, 0 insertions, 87 deletions
diff --git a/.local/bin/gittab b/.local/bin/gittab
deleted file mode 100755
index 5ffd5f9..0000000
--- a/.local/bin/gittab
+++ /dev/null
@@ -1,87 +0,0 @@
-#! /usr/bin/env perl6
-
-use v6.d;
-
-constant TABDIR = $*HOME.add('.local/etc/gittab/tabs');
-constant TABCONF = $*HOME.add('.local/etc/gittab/basedirs');
-
-#| Update managed git repositories
-multi sub MAIN (
- #| A list of targets to update.
- *@targets,
-) {
- @targets = TABDIR.dir.map(*.basename) unless @targets;
-
- for @targets -> $target {
- my $tab = find-tab($target);
-
- note "No gittab for target '$target'" unless $tab;
-
- my $basedir = get-basedir($target);
-
- mkdir($basedir) unless $basedir.d;
-
- for $tab.lines.grep(!*.starts-with("#")) {
- my ($name, $repo, $branch) = $_.words;
-
- if (!$basedir.add($name).d) {
- chdir $basedir;
- run « git clone --single-branch --branch "$branch" --depth 1 "$repo" "$name" »;
- }
-
- chdir $basedir.add($name);
- run « git checkout "$branch" »;
- run « git pull "$repo" "$branch" »;
- }
- }
-}
-
-#| List managed git repositories
-multi sub MAIN (
- Bool:D :$list!,
-) {
- my @tabs = TABDIR.dir.map(*.basename).sort;
- my $longest = @tabs.map(*.chars).sort.tail;
-
- for @tabs {
- "%-{$longest}s %s\n".printf($_, get-basedir($_));
- }
-}
-
-sub find-tab (
- Str:D $name,
-) {
- my @attempts =
- $name,
- $name ~ 'tab',
- ;
-
- for @attempts {
- my $fh = TABDIR.add($_);
-
- return $fh if $fh.f;
- }
-
- Nil;
-}
-
-sub get-basedir (
- Str:D $tab,
-) {
- state %basedirs;
-
- if (!%basedirs && TABCONF.e) {
- TABCONF
- .lines
- .grep(!*.starts-with('#'))
- .map({
- my ($tab, $basedir) = $_.words;
-
- %basedirs{$tab} = $basedir.IO;
- })
- }
-
- return $*HOME unless %basedirs{$tab}:exists;
-
- $*HOME.add(%basedirs{$tab});
-}