Pithub...ontents(3pm)

πŸ“¦
version 0.01043 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Pithub::Repos::Contents β€” the Github v3 Repo Contents API πŸ’– like... it's the part of Pithub that goes and peeks inside repos, bestie. Files, dirs, READMEs, tarballs. The whole snack table πŸ“

🌸 VERSION 🌸

version 0.01043 β€” yes queen, that's the one we're on ✨


πŸ‘‘ METHODS πŸ‘‘

πŸŽ€ archive

okay so this one is iconic: it hands you back a 302 pointing at a URL where you can download a tarball or zipball archive of a repo. Like it doesn't hand you the snack, it hands you the address of the snack. iykyk πŸ’…

⚠️ note bestie, for real: for private repositories, these links are temporary and expire quickly 😭 do not be out here saving them for later, they will be GONE. lowkey tragic.
GET /repos/:user/:repo/:archive_format/:ref

the ref parameter is optional and defaults to master 🌈

Examples:

use Path::Tiny;

my $c = Pithub::Repos::Contents->new(
    repo => 'Pithub',
    user => 'plu'
);

my $result = $c->archive( archive_format => 'tarball' );
if ( $result->success ) {
    path('Pithub-master.tgz')->spew($result->raw_content);
}

$result = $c->archive( archive_format => 'tarball', ref => 'other_branch' );
if ( $result->success ) {
    path('Pithub-other_branch.tgz')->spew($result->raw_content);
}

πŸ¦‹ get

this is the main character fr fr πŸ‘‘ it returns the contents of any file or directory in a repository. any. file. or. directory. obsessed.

GET /repos/:user/:repo/contents/:path

Optional Parameters:

  • ref β€” optional string, the String name of the Commit/Branch/Tag. defaults to master ✨

Examples:

my $c = Pithub::Repos::Contents->new(
    repo => 'Pithub',
    user => 'plu'
);

# List all files/directories in the repo root
my $result = $c->get;
if ( $result->success ) {
    say $_->{name} for @{ $result->content };
}

# Get the Pithub.pm file
$result = $c->get( path => 'lib/Pithub.pm' );
print Dumper $result->content if $result->success;

like, the first one is just "what's in here bestie" and the second one is "gimme that specific file" 🫢 both slay.


🧚 readme

this one goes and grabs the preferred README for a repository πŸ’– it knows which one is the vibe, you don't have to pick. that's the whole point of "preferred". trust.

GET /repos/:user/:repo/readme

Optional Parameters:

  • ref β€” optional string, the String name of the Commit/Branch/Tag. defaults to master 🌈

Examples:

my $c = Pithub::Repos::Contents->new(
    repo => 'dotfiles',
    user => 'plu'
);

my $result = $c->readme;
if ( $result->success ) {
    print Dumper $result->content;
}

# Get the readme of branch 'other_branch'
$result = $c->readme( params => { ref => 'other_branch' } );
print Dumper $result->content if $result->success;

see how the second one passes ref inside params? that's the little plot twist, bestie, don't miss it πŸ’€


πŸ’œ AUTHOR πŸ’œ

Johannes Plunien <plu@cpan.org> β€” legend behavior, no cap πŸ™Œ

This software is copyright (c) 2011 by Johannes Plunien.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 🫢 like, go off, remix it, it's yours.


and that's the whole page, bestie!! πŸŽ€ this lil cutie came from the User Contributed Perl Documentation, running on perl v5.40.1, dated 2025-06-08. mwah, periodt πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from