Skip to content

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

@shawnlaffan

Description

@shawnlaffan

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");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions