#!/usr/bin/env perl use strict; use warnings; # hg config経由でhgrcにかかれているpush先を確認する my $push_path = `hg config paths.default`; if ($?){ print "[eror] failed exec hg config paths.default"; exit 1; } my $open_cmd = $^O eq 'darwin' ? "open" : "xdg-open"; #linux open cmd is xdg-open # 無かったら特に何もしない exit 1 unless ($push_path); # yomitanはパスで開けないので別枠 my $url; if ($push_path =~ /(yomitan)|(chatan)/){ $url = yomitan($push_path); } elsif ($push_path =~ /firefly/){ $url = firefly($push_path); } else { if ( $push_path =~ m[(https?|ssh)://(\w+@)?(.*)]){ $url = "http://$3"; } die 'invalid url'; } `$open_cmd $url`; sub yomitan { my $input = shift; my $http_domain = 'https://ie.u-ryukyu.ac.jp/hg/'; my $url; if ($input =~ m[.*//home/hg/y(\d+)(.+)]){ $url = $http_domain . "y$1$2"; } return $url; } sub firefly { my $input = shift; my $http_domain = 'http://www.cr.ie.u-ryukyu.ac.jp/'; my $url; if (($input =~ m[.*?firefly.cr.ie.u-ryukyu.ac.jp/(.*)] )||($input =~ m[.*firefly/(.*)])){ $url = $http_domain.$1; } return $url; }