Skip to content

Instantly share code, notes, and snippets.

@dlangille
Created November 24, 2020 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/403b620e1b896654ade35effe8da9774 to your computer and use it in GitHub Desktop.
Save dlangille/403b620e1b896654ade35effe8da9774 to your computer and use it in GitHub Desktop.
FreshPorts element strip repo head /ports/head /ports/branches/2020Q4
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