gl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/usr/bin/perl
  2. my $pager = `which less` || `which more`;
  3. my $tmpdir = "/tmp/FSJIRA";
  4. system("mkdir -p $tmpdir");
  5. my $cmd = "git log " . join(" ", @ARGV);
  6. open(CMD, "$cmd |");
  7. open(PAGER, "|$pager");
  8. select PAGER;
  9. while(my $line = <CMD>) {
  10. print $line;
  11. if ($line =~ /([A-Z]+\-[0-9]+)/) {
  12. my $bug = $1;
  13. my $txt = bugtxt($bug);
  14. if ($txt) {
  15. print "=" x 80 . "\n";
  16. print $txt;
  17. print "=" x 80 . "\n";
  18. }
  19. }
  20. }
  21. close(CMD);
  22. close(PAGER);
  23. sub catfile($) {
  24. my $file = shift;
  25. open(I, $file) or return;
  26. $/ = undef;
  27. my $txt = <I>;
  28. $/ = "\n";
  29. close(I);
  30. return $txt;
  31. }
  32. sub bugtxt($)
  33. {
  34. my $bug = shift or return "";
  35. my $now = time;
  36. my $tmp;
  37. $bug =~ s/\.\.//g;
  38. $bug =~ s/^\///g;
  39. $bug =~ s/~//g;
  40. $bug =~ s/[^a-zA-Z0-9\-]//g;
  41. $tmp = "$tmpdir/$bug.txt";
  42. if(-f $tmp) {
  43. return catfile($tmp);
  44. }
  45. my $cmd = "wget -q https://freeswitch.org/jira/si/jira.issueviews:issue-xml/$bug/$bug.xml -O $tmp";
  46. system($cmd);
  47. my $txt = catfile($tmp);
  48. my ($a,$title) = $txt =~ /\<title\>(.*?)\<\/title\>/smg;
  49. my ($status) = $txt =~ /\<status.*?\>(.*?)\<\/status\>/smg;
  50. my ($a,$des) = $txt =~ /\<description\>(.*?)\<\/description\>/smg;
  51. my ($alogin, $aname) = $txt =~ /\<assignee username=\"([^\"]+)\"\>(.*?)\<\/assignee\>/smg;
  52. my ($rlogin, $rname) = $txt =~ /\<reporter username=\"([^\"]+)\"\>(.*?)\<\/reporter\>/smg;
  53. if ($rname && $aname) {
  54. my $data = "$title\nReporter: $rname [$rlogin]\nAssignee: $aname [$alogin]\nStatus: $status\nhttps://freeswitch.org/jira/browse/$bug\n";
  55. open(O, ">$tmp");
  56. print O $data;
  57. close(O);
  58. return $data;
  59. } else {
  60. unlink($tmp);
  61. }
  62. }