From 3dbbc5f0dd6d59e0cf020c28b9b9d5d70cc19c1b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 21 Jan 2012 10:36:35 +0000 Subject: [PATCH] wip create, forgot to add --- tg-create.pl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tg-create.pl diff --git a/tg-create.pl b/tg-create.pl new file mode 100644 index 0000000..f0bd563 --- /dev/null +++ b/tg-create.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use Getopt::Long; +use Topbloke; + +Getopt::Long::Configure(qw(bundling)); + +die "bad usage\n" unless @ARGV==1; + +our $spec = parse_branch_spec($ARGV[0]); +our $current = current_tb_branch(); + +die "cannot make branch starting at base of another;". + " check out a real branch\n" if $current->{Kind} eq 'base'; + +die "strange branch ref $current->{Kind} $current->{Ref},\n". + " making new branch with this as dep is unwise\n" + unless ($current->{Kind} eq 'foreign' || + $current->{Kind} eq 'tip'); + +sub fillin ($$$) { + my ($key, $newval, $what) = @_; + return if defined $spec->{$key}; + $spec->{$key} = $newval; +} + +if (!defined $spec->{Email} || !defined $spec->{Domain}) { + my $eaddr = run_git_1line(qw(config user.email)); + $eaddr =~ m/^(.*)\@/ or die "$eaddr ?"; + fillin('Email',$1,'email domain'); + fillin('Domain',$','email domain'); #'); +} + +if (!defined $spec->{Date}) { + $spec->{Date} = `LC_TIME=C date -u +%Y-%m-%dT%H%M%SZ`; + chomp $spec->{Date} or die $!; +} + +length($spec->{Date})==18 or die "partial date specified, not supported\n"; + +my $newbranch = "$spec->{Email}\@$spec->{Domain}/$spec->{Date}/$spec->{Nick}"; + +$newbranch = run_git_1line(qw(check-ref-format --print), $newbranch); + +printf "creating %s\n", $newbranch; + +setup_config(); -- 2.30.2