From: b Date: Thu, 28 Sep 2023 08:19:30 +0000 (+0200) Subject: Add pushing X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=b58419f96f1a8aeb66ad64f2b226ea48645e9815;p=cresnov%2Fimagimoth-tracker Add pushing --- diff --git a/moth.pl b/moth.pl index 705ed8a..7ffec15 100755 --- a/moth.pl +++ b/moth.pl @@ -20,6 +20,7 @@ use constant WGET => 'wget'; use constant ZBARIMG => 'zbarimg'; use constant CONVERT => 'convert'; use constant CROP => '56x57+194+81'; +use constant GIT_REMOTE => 'http://bicyclesonthemoon.info/git/cresnov/imagimoth-family-tree'; use constant ATTACHMENT_URL_BASE => 'https://cresnov.com/attachments/'; use constant TREE_PATH => '/home/b/cresnov/imagimoth/tree/'; use constant TREE_MOTH_PATH => '/home/b/cresnov/imagimoth/tree/moth.png'; @@ -146,7 +147,10 @@ elsif ($action eq 'x') { goto_branch($parent_a); } - +elsif ($action eq 'pushout') { + goto_tree(); + push_out(); +} else { print STDERR "Invalid action: $action.\n"; exit 1; @@ -262,7 +266,7 @@ sub merge_start { } my $r = system_encoded(GIT(), ( GIT(), 'merge', - '--no-commit', '--allow-unrelated-histories', # '--no-verify', + '--no-commit', '--allow-unrelated-histories', '--no-ff', # '--no-verify', '-s', 'ours', # hack '-m', $text, $name, @@ -311,7 +315,7 @@ sub add_moth { print STDERR "Copy QR fail.\n"; exit 1; } - my $r = my $r = system_encoded(GIT(), ( + my $r = system_encoded(GIT(), ( GIT(), 'add', '.' )); if ($r != 0) { @@ -323,7 +327,7 @@ sub add_moth { sub commit { (my $text) = @_; - my $r = my $r = system_encoded(GIT(), ( + my $r = system_encoded(GIT(), ( GIT(), 'commit', '--allow-empty-message', '-m', $text )); if ($r != 0) { @@ -331,3 +335,31 @@ sub commit { exit 1; } } + +sub push_out { + my $r; + + $r = system_encoded(GIT(), ( + GIT(), 'remote', 'add', 'origin', GIT_REMOTE() + )); + if ($r != 0) { + print STDERR "Git remote add fail.\n"; + exit 1; + } + + $r = system_encoded(GIT(), ( + GIT(), 'push', '--all', '--force' + )); + if ($r != 0) { + print STDERR "Git push fail.\n"; + exit 1; + } + + $r = system_encoded(GIT(), ( + GIT(), 'remote', 'remove', 'origin' + )); + if ($r != 0) { + print STDERR "Git remote remove fail.\n"; + exit 1; + } +} \ No newline at end of file