Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set .gitattributes files to render alienfiles as perl across PerlAlien repos #8

Open
shawnlaffan opened this issue Nov 28, 2022 · 2 comments

Comments

@shawnlaffan
Copy link

alienfiles are pure perl code but render on GitHub as plain text. This can be corrected by adding this line to a .gitattributes file in each repo:

alienfile linguist-language=perl

I would submit PRs but there are too many repos under the organisation for this to be efficient. The script below is one approach to automation assuming all repos are at the same level.

use 5.010;
use strict;
use warnings;

use Path::Tiny;
use Cwd qw /getcwd/;

my @dirs = grep {-d} (path (getcwd())->children);

foreach my $dir (@dirs) {
    my $has_alienfile = grep {path($_)->basename eq 'alienfile'} (path($dir)->children);
    next if !$has_alienfile;
    my $file = path($dir, '.gitattributes');
    $file->touch;
    my $contents = $file->slurp;
    if (not $contents =~ /alienfile/ms) {
        $file->append("alienfile linguist-language=perl\n");
    }
}
@plicease
Copy link
Member

Good point. I have a script which can make this change to all the repos in this org (and some in PerlFFI + uperl orgs which also have alienfile), but I usually only run it when I have a batch of changes to make, often when I have to bump CI for new Perls. I've added a note to do it then.

@shawnlaffan
Copy link
Author

Thanks. Doing it as part of the next batch update sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants