Skip to content

Add an option to clone package repo instead of downloading a tarball #150

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packer
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ usage() {
echo ' -Ss|-Ssq - searches for package'
echo ' -Si - outputs info for package'
echo ' -G - download and extract aur tarball only'
echo ' -C - clone/pull the package aur git repository'
echo
echo ' --quiet - only output package name for searches'
echo ' --ignore - takes a comma-separated list of packages to ignore'
Expand Down Expand Up @@ -522,6 +523,7 @@ while [[ $1 ]]; do
'-Si') option=info ;;
-S*u*) option=update ; pacmanarg="$1" ;;
'-G') option=download ;;
'-C') option=git ;;
'-h'|'--help') usage ;;
'--quiet') quiet='1' ;;
'--ignore') ignorearg="$2" ; PACOPTS+=("--ignore" "$2") ; shift ;;
Expand Down Expand Up @@ -655,6 +657,34 @@ if [[ $option = download ]]; then
done
fi


# Git clone/pull handling

if [[ $option = git ]]; then
for package in "${packageargs[@]}"; do
if existsinaur "$package"; then
pkglist+=("$package")
else
err "Package \`$package' does not exist on aur."
fi
done

for package in "${pkglist[@]}"; do
clone_link="${PKGURL}/${package}.git"

# if a clone already exists, try to pull
# otherwise clone.
if [[ -d "$package/.git" ]]; then
cd "$package"
git pull "${clone_link}"
cd ..
else
# shallow clone
git clone --depth 1 "${clone_link}" "${package}"
fi
done
fi

# Search (-Ss) handling
if [[ $option = search || $option = searchinstall ]]; then
# Pacman searching
Expand Down
5 changes: 5 additions & 0 deletions packer.8
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ Show information for a package\&.
Download and extract AUR package tarballs, but don\(cqt install anything\&.
.RE
.PP
\fB\-C\fR
.RS 4
Using git, clone or update the AUR package repositories, but don\(cqt install anything\&.
.RE
.PP
\fB\-h\fR
.RS 4
Show packer usage\&.
Expand Down