X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=stodo;h=7cc9b5dde45b768bc7a12b2c5d17cc40df61686a;hb=e88885b27f22602722e9087b31c073a64f0b06ca;hp=d13fae7200dbfaf06c48955ec59ea509c6564c77;hpb=94e4d50539e8694d969d5ace319329b9ed95f250;p=bin.git diff --git a/stodo b/stodo old mode 100644 new mode 100755 index d13fae7..7cc9b5d --- a/stodo +++ b/stodo @@ -1,9 +1,9 @@ #! /usr/bin/perl -# ss makes a screenshot of the screen using import, and is released -# under the terms of the GPL version 2, or any later version, at your -# option. See the file README and COPYING for more information. -# Copyright 2004 by Don Armstrong . -# $Id: ss,v 1.3 2004/09/27 05:58:55 don Exp $ +# stodo commits the changes made to a subversion backed todo db, and +# is released under the terms of the GPL version 2, or any later +# version, at your option. See the file README and COPYING for more +# information. Copyright 2004 by Don Armstrong . +# $Id$ use warnings; @@ -54,6 +54,20 @@ Display this manual. =back +=head1 ENVIRONMENTAL VARIABLES + +=over + +=item B + +Todo databse location, set by devtodo + +=item B + +If set, stodo assumes that there is no network, and doesn't commit + +=back + =head1 EXAMPLES on save { @@ -85,22 +99,31 @@ my %options = (quiet => 0, GetOptions(\%options,'debug|d+','help|h|?','man|m','quiet|q+','simulate|s+'); -pod2usage() if $options{help} or not exists $ENV{TODODB}; +pod2usage() if $options{help}; pod2usage({verbose=>2}) if $options{man}; $DEBUG = $options{debug}; # Figure out what we're doing -my $tododb = $ENV{TODODB}; +my $tododb = exists $ENV{TODODB} ? $ENV{TODODB} : '.todo'; if ($tododb !~ m#^/#) { $tododb = cwd().'/'.$tododb; } +if (not -r $tododb) { + print STDERR "Todo DB '$tododb' does not exist or is not readable\n"; + exit 1; +} $tododb = full_readlink($tododb); my $base_dir = dirname($tododb); my $tododb_name = basename($tododb); if (not -e "$base_dir/.svn") { - print "$base_dir/.svn doesns't exist, not commiting" unless $options{quiet}; + print STDERR "$base_dir/.svn doesn't exist, not commiting\n" unless $options{quiet}; + exit 0; +} + +if (not -e "$base_dir/.svn/text-base/${tododb_name}.svn-base") { + print STDERR "$base_dir/.svn/text-base/${tododb_name}.svn-base doesn't exist, not committing\n" unless $options{quiet}; exit 0; } @@ -110,20 +133,23 @@ my $svn_entries_fh = new IO::File "$base_dir/.svn/entries",'r' my $url_type; my $svn_host; while (<$svn_entries_fh>) { - next unless m#^\s+url=\"(http|svn\+ssh|file):///?([^\/]+)#; + next unless m#^(?:\s+url=\")?(http|svn\+ssh|file):///?([^\/]+)#; $url_type = $1; last if $url_type eq 'file'; $svn_host = $2; last; } - -if (not defined $svn_host and $url_type ne 'file') { +if ($ENV{STODO_NO_COMMIT}) { + print STDERR "Exiting because of STODO_NO_COMMIT env variable\n" unless $options{quiet}; + exit 0; +} +if (not defined $svn_host and (not defined $url_type or $url_type ne 'file')) { die "Was unable to find which host the svn repository is located on"; } if ($url_type ne 'file') { qx(ping -q -c 3 $svn_host >/dev/null 2>&1); if ($? != 0) { - print "Unable to ping $svn_host" unless $options{quiet}; + print "Unable to ping $svn_host\n" unless $options{quiet}; exit 0 unless $options{simulate}; } } @@ -235,6 +261,9 @@ else { sub fix_content { my ($s) = @_; + if (not ref(${[values %{$s}]}[0]) eq 'HASH') { + $s = {$s->{time} => $s}; + } foreach my $entry (values %{$s}) { if (exists $entry->{content}) { $entry->{content} =~ s/^\s*|\s*$//g;