findMergedChanges.pl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. sub nChanges {
  5. my ($branches, $fname) = @_;
  6. local *F;
  7. # requires perl 5.8. Avoids shell issues if we ever get a changes
  8. # file named by the parents of Little Johnny Tables.
  9. open F, "-|", "git", "log", "--pretty=format:%H", $branches, "--", $fname
  10. or die "$!";
  11. my @changes = <F>;
  12. return scalar @changes
  13. }
  14. my $look_for_type = "merged";
  15. while (@ARGV and $ARGV[0] =~ /^--/) {
  16. my $flag = shift @ARGV;
  17. if ($flag =~ /^--(weird|merged|unmerged|list)/) {
  18. $look_for_type = $1;
  19. } else {
  20. die "Unrecognized flag $flag";
  21. }
  22. }
  23. for my $changefile (@ARGV) {
  24. my $n_merged = nChanges("origin/release-0.2.2", $changefile);
  25. my $n_postmerged = nChanges("origin/release-0.2.2..origin/master", $changefile);
  26. my $type;
  27. if ($n_merged != 0 and $n_postmerged == 0) {
  28. $type = "merged";
  29. } elsif ($n_merged == 0 and $n_postmerged != 0) {
  30. $type = "unmerged";
  31. } else {
  32. $type = "weird";
  33. }
  34. if ($type eq $look_for_type) {
  35. print "$changefile\n";
  36. } elsif ($look_for_type eq 'list') {
  37. printf "% 8s: %s\n", $type, $changefile;
  38. }
  39. }