SHARE
TWEET

Untitled

a guest Apr 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2.  
  3. # Converts a gitlog file to a list of edges in an undirected weighted graph
  4. # Author: Aron Lurie
  5. # Date: 2018-08-15
  6. # Usage: git log --pretty=oneline --name-only | perl git.pl > mylogfile.txt
  7.  
  8. my @files = ();
  9. my %adjacent = ();
  10. while (<STDIN>) {
  11.     chomp;
  12.     if ($_ =~ /[a-f0-9]{40} /) {
  13.         if (@files) {
  14.             for my $filename (@files) {
  15.                 for my $other_filename (@files) {
  16.                     next if ($filename > $other_filename);
  17.                     $adjacent{$filename}{$other_filename}++;
  18.                 }
  19.             }
  20.         }
  21.         @files = ();
  22.     } else {
  23.         push @files,  $_;
  24.     }
  25. }
  26.  
  27. for my $filename (keys %adjacent) {
  28.     for my $other_filename (keys %{ $adjacent{$filename} }) {
  29.         my $conn = $adjacent{$filename}{$other_filename};
  30.         print join(",", ($filename, $other_filename, 1000/$conn)), "\n";
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top