diff options
author | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
commit | 6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch) | |
tree | 34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/build-scripts/git-pre-push-hook.pl | |
parent | 8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff) |
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/build-scripts/git-pre-push-hook.pl')
-rwxr-xr-x | src/contrib/SDL-3.2.20/build-scripts/git-pre-push-hook.pl | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/build-scripts/git-pre-push-hook.pl b/src/contrib/SDL-3.2.20/build-scripts/git-pre-push-hook.pl new file mode 100755 index 0000000..63596b6 --- /dev/null +++ b/src/contrib/SDL-3.2.20/build-scripts/git-pre-push-hook.pl | |||
@@ -0,0 +1,78 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | |||
3 | # To use this script: symlink it to .git/hooks/pre-push, then "git push" | ||
4 | # | ||
5 | # This script is called by "git push" after it has checked the remote status, | ||
6 | # but before anything has been pushed. If this script exits with a non-zero | ||
7 | # status nothing will be pushed. | ||
8 | # | ||
9 | # This hook is called with the following parameters: | ||
10 | # | ||
11 | # $1 -- Name of the remote to which the push is being done | ||
12 | # $2 -- URL to which the push is being done | ||
13 | # | ||
14 | # If pushing without using a named remote those arguments will be equal. | ||
15 | # | ||
16 | # Information about the commits which are being pushed is supplied as lines to | ||
17 | # the standard input in the form: | ||
18 | # | ||
19 | # <local ref> <local sha1> <remote ref> <remote sha1> | ||
20 | |||
21 | use warnings; | ||
22 | use strict; | ||
23 | |||
24 | my $remote = $ARGV[0]; | ||
25 | my $url = $ARGV[1]; | ||
26 | |||
27 | #print("remote: $remote\n"); | ||
28 | #print("url: $url\n"); | ||
29 | |||
30 | $url =~ s/\.git$//; # change myorg/myproject.git to myorg/myproject | ||
31 | $url =~ s#^git\@github\.com\:#https://github.com/#i; | ||
32 | my $commiturl = $url =~ /\Ahttps?:\/\/github.com\// ? "$url/commit/" : ''; | ||
33 | |||
34 | my $z40 = '0000000000000000000000000000000000000000'; | ||
35 | my $reported = 0; | ||
36 | |||
37 | while (<STDIN>) { | ||
38 | chomp; | ||
39 | my ($local_ref, $local_sha, $remote_ref, $remote_sha) = split / /; | ||
40 | #print("local_ref: $local_ref\n"); | ||
41 | #print("local_sha: $local_sha\n"); | ||
42 | #print("remote_ref: $remote_ref\n"); | ||
43 | #print("remote_sha: $remote_sha\n"); | ||
44 | |||
45 | my $range = ''; | ||
46 | if ($remote_sha eq $z40) { # New branch, examine all commits | ||
47 | $range = $local_sha; | ||
48 | } else { # Update to existing branch, examine new commits | ||
49 | $range = "$remote_sha..$local_sha"; | ||
50 | } | ||
51 | |||
52 | my $gitcmd = "git log --reverse --oneline --no-abbrev-commit '$range'"; | ||
53 | open(GITPIPE, '-|', $gitcmd) or die("\n\n$0: Failed to run '$gitcmd': $!\n\nAbort push!\n\n"); | ||
54 | while (<GITPIPE>) { | ||
55 | chomp; | ||
56 | if (/\A([a-fA-F0-9]+)\s+(.*?)\Z/) { | ||
57 | my $hash = $1; | ||
58 | my $msg = $2; | ||
59 | |||
60 | if (!$reported) { | ||
61 | print("\nCommits expected to be pushed:\n"); | ||
62 | $reported = 1; | ||
63 | } | ||
64 | |||
65 | #print("hash: $hash\n"); | ||
66 | #print("msg: $msg\n"); | ||
67 | |||
68 | print("$commiturl$hash -- $msg\n"); | ||
69 | } else { | ||
70 | die("$0: Unexpected output from '$gitcmd'!\n\nAbort push!\n\n"); | ||
71 | } | ||
72 | } | ||
73 | die("\n\n$0: Failing exit code from running '$gitcmd'!\n\nAbort push!\n\n") if !close(GITPIPE); | ||
74 | } | ||
75 | |||
76 | print("\n") if $reported; | ||
77 | |||
78 | exit(0); # Let the push go forward. | ||