Created
November 24, 2020 19:18
-
-
Save dlangille/403b620e1b896654ade35effe8da9774 to your computer and use it in GitHub Desktop.
FreshPorts element strip repo head /ports/head /ports/branches/2020Q4
This file contains 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
sub StripLeadingPrefix { | |
# take an element name, and remove the leading /ports/head or /ports/branches/foo from the path name | |
# for example: /ports/head/lang/yap/Makefile | |
# /ports/head/lang/yap/files/patch-Makefile.in | |
# /ports/head/lang/yap/pkg-descr | |
# split the incoming path up by / | |
# This will have a leading /, so we wind up with | |
# | |
# $VAR1 = ''; | |
# $VAR2 = 'ports'; | |
# $VAR3 = 'head'; | |
# | |
# for example. | |
# | |
my @path = split '/', shift; | |
# empty the first three elements, and that returns the first element, | |
# which if is 'branches', remove that element too. | |
splice(@path, 0, 3) eq "branches" and shift @path; | |
# add a / to the front of the path | |
join '/', @path; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment