Created
August 26, 2022 06:44
-
-
Save rajatjindal/e07890f5da256c5e76b7bf18173b19cd to your computer and use it in GitHub Desktop.
generate crucible compatible diff from git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| my $gitrev = $ARGV[0]; | |
| if (!$gitrev) { | |
| die "usage: gitdiff <a51335c5c5e40fad2b788cdea1b2f7bba6c229eb>\n"; | |
| } | |
| my $svnrev = `git show $gitrev | grep git-svn-id | awk -F'\@' '{print \$2}' | awk '{print \$1}'`; | |
| $svnrev =~ s/^\s+|\s+$//g; | |
| my $origdiff = `git diff $gitrev`; | |
| my $time = time() * 1000; | |
| my $newdiff = $origdiff; | |
| my $seperator = "<+>UTF-8\n==================================================================="; | |
| $newdiff =~ s!diff --git a/.* b/(.*)!Index: $1!g; | |
| $newdiff =~ s!index .* \d{6}!$seperator!g; | |
| $newdiff =~ s!(---.*)!$1 (revision $svnrev)!g; | |
| $newdiff =~ s!(\+\+\+.*)!$1 (date $time)!g; | |
| print $newdiff; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment