Skip to content

Commit 2f8208e

Browse files
committed
Merge branch 'private-repos' into final
2 parents ec0b122 + 04ff728 commit 2f8208e

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

bin/github-backup

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ Options:
6969
EOF
7070
exit;
7171
}
72+
73+
# If cloning private repos it is necessary to pass the authentication
74+
# information to the git command. It is not possible to do this using
75+
# Git::Repository, so an alternative is to use git's GIT_ASKPASS option, which
76+
# is a command to run that will return the password (it is not possible to pass
77+
# the password directly in an environment variable). The github_backup_pass
78+
# command simply echos the GITHUB_TOKEN value, which can be used in place of a
79+
# password for authentication, thus allowing access to the private repos. This
80+
# option is ignored if it doesn't exist or returns nothing.
81+
$ENV{GIT_ASKPASS}="github_backup_pass";
82+
7283
my $gh = Github::Backup->new(
7384
api_user => $opts{user},
7485
token => $opts{token},

bin/github-backup-pass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
echo $GITHUB_TOKEN

lib/Github/Backup.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ Mandatory: Your Github username.
295295
296296
Mandatory: Your Github API token. If you wish to not include this on the
297297
command line, you can put the token into the C<GITHUB_TOKEN> environment
298-
variable.
298+
variable. Specifying the token in the C<GITHUB_TOKEN> environment variable also
299+
enables private repositories to be accessed, as github_backup will use the
300+
environment variable via the github_backup_pass command and git's
301+
C<GIT_ASKPASS> option to pass the required authentication information to git
302+
when cloning a repository.
299303
300304
=head2 -l | --list
301305

0 commit comments

Comments
 (0)