#!perl

use 5.010001;
use strict;
use warnings;
use Log::ger::Screen;

use App::GitUtils;
use Cwd;
use Getopt::Long;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2025-04-16'; # DATE
our $DIST = 'App-GitUtils'; # DIST
our $VERSION = '0.087'; # VERSION

Getopt::Long::Configure("bundling", "no_ignore_case");
my $quiet;
GetOptions(
    "quiet|q" => \$quiet,
);

my $cwd = Cwd::getcwd();
my $res = App::GitUtils::info(dir => $cwd);

if ($res->[0] == 200) {
    print $res->[2]{repo_name}, "\n";
} else {
    if ($quiet) {
    } else {
        warn "this-repo: No git repository can be associated with current directory '$cwd'\n";
    }
    exit 1;
}

# ABSTRACT: Return name of git repository associated with current directory
# PODNAME: this-repo

__END__

=pod

=encoding UTF-8

=head1 NAME

this-repo - Return name of git repository associated with current directory

=head1 VERSION

This document describes version 0.087 of this-repo (from Perl distribution App-GitUtils), released on 2025-04-16.

=head1 SYNOPSIS

 % pwd
 /home/budi/perl-Foo-Bar

 % this-repo
 perl-Foo-Bar

 # Will exit with code 1 and print error message to stderr when git repository cannot be determined
 % cd /
 % this-repo
 this-repo: No git repository can be associated with current directory '/'

 # Don't show error message when guessing is failed (just exit with code 1)
 % this-repo -q
 % _

=head1 DESCRIPTION

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-GitUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-GitUtils>.

=head1 SEE ALSO

L<gu>. C<this-repo> has roughly the same utility as C<gu info>.

L<this-repo-on-github> from L<App::GitHubUtils>

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 CONTRIBUTING


To contribute, you can send patches by email/via RT, or send pull requests on
GitHub.

Most of the time, you don't need to build the distribution yourself. You can
simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your
system), you can install L<Dist::Zilla>,
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
that are considered a bug and can be reported to me.

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2025 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-GitUtils>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=cut
