6 Commits

Author SHA1 Message Date
Ivan Malopinsky bcde137050 bump to 1.5.0 2016-03-09 19:43:58 -05:00
Ivan Malopinsky da31f19926 Merge pull request #66 from imsky/quotes-xargs
fix xargs failure for branches with quotes in names
2016-03-08 23:40:56 -05:00
Ivan Malopinsky 2b1fb56c4a fix xargs failure for branches with quotes in names
fix #65
2016-03-08 23:40:44 -05:00
Ivan Malopinsky 4f142bf0dd update readme to include tag option 2016-02-28 00:06:48 -05:00
Ivan Malopinsky 5c76da3ebd Merge pull request #64 from imsky/stale-tags
remove local tags that do not exist on remote, fix #62
2016-02-27 18:35:53 -05:00
Ivan Malopinsky 0d632b15e1 remove local tags that do not exist on remote, fix #62 2016-02-27 18:35:29 -05:00
3 changed files with 30 additions and 7 deletions
+3 -2
View File
@@ -5,15 +5,16 @@ Keep your repo fresh with one command.
## Usage
```
Usage: git fresh [-fmrF] [-sl] [remote] [root]
Usage: git fresh [-fmrtF] [-sl] [remote] [root]
By default, git-fresh will:
- rebase against remote current branch
- rebase against remote current branch
- stash changes
- prune remote branches
-f: Delete stale local and remote branches
-m: Merge remote root into current branch
-r: Rebase current branch against remote root
-t: Remove local tags that do not exist on remote
-F: Reset local root to remote root, wipe workspace
-s: Apply stashed changes after run
+26 -4
View File
@@ -7,7 +7,7 @@
usage () {
cat << EOD
Usage: git fresh [-fmrF] [-sl] [remote] [root]
Usage: git fresh [-fmrtF] [-sl] [remote] [root]
By default, git-fresh will:
- rebase against remote current branch
- stash changes
@@ -16,6 +16,7 @@ By default, git-fresh will:
-f: Delete stale local and remote branches
-m: Merge remote root into current branch
-r: Rebase current branch against remote root
-t: Remove local tags that do not exist on remote
-F: Reset local root to remote root, wipe workspace
-s: Apply stashed changes after run
@@ -43,7 +44,7 @@ error () {
trap 'error $LINENO' ERR
while getopts ":fmrslF" opt; do
while getopts ":fmrtslF" opt; do
case $opt in
f)
FORCE_DELETE_STALE=true
@@ -54,6 +55,9 @@ while getopts ":fmrslF" opt; do
r)
REBASE=true
;;
t)
TAGS=true
;;
s)
APPLY_STASH=true
;;
@@ -136,7 +140,7 @@ if [[ ! -z "${SMART_STALE// }" ]]; then
if [[ ! -z "${LOCAL_STALE// }" ]]; then
STALE_BRANCHES=true
if [[ "$FORCE_DELETE_STALE" = true ]]; then
echo -n $LOCAL_STALE | xargs git branch -d 2> /dev/null
echo -n $LOCAL_STALE | xargs -0 git branch -d 2> /dev/null
else
say "Local stale branches found:" $(echo -n $LOCAL_STALE | tr "\n" " ")
fi
@@ -146,7 +150,7 @@ if [[ ! -z "${SMART_STALE// }" ]]; then
STALE_BRANCHES=true
if [[ "$FORCE_DELETE_STALE" = true ]]; then
if [[ "$DELETE_ONLY_LOCAL" != true ]]; then
echo -n $REMOTE_STALE | xargs git push $REMOTE --delete
echo -n $REMOTE_STALE | xargs -0 git push $REMOTE --delete
fi
else
say "Remote stale branches found:" $(echo -n $REMOTE_STALE | tr "\n" " ")
@@ -158,6 +162,8 @@ if [[ ! -z "${SMART_STALE// }" ]]; then
fi
fi
# Rebase or merge remote root against local branch
if [[ ! -z $(git rev-parse --verify --quiet "$CURRENT") ]]; then
git checkout $CURRENT 2> /dev/null
@@ -176,6 +182,22 @@ else
echo "$CURRENT branch was stale, staying on $ROOT"
fi
# Remove local tags that are missing on the remote
if [[ "$TAGS" = true ]]; then
REMOTE_TAGS=$(git ls-remote --tags $REMOTE | cut -f 2)
LOCAL_TAGS=$(git show-ref --tags | cut -d' ' -f 2)
for tag in $LOCAL_TAGS; do
if [[ -z $(grep $tag <<< "$REMOTE_TAGS" | cat) ]]; then
MISSING_TAG="${tag//refs\/tags\/}"
git tag -d $MISSING_TAG
fi
done
fi
# Restore stashed changes
if [[ ! -z $(git stash list | grep $STASH_STAMP | cat) ]]; then
if [[ "$APPLY_STASH" = true ]]; then
git stash pop
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "git-fresh",
"version": "1.4.0",
"version": "1.5.0",
"description": "Utility to keep Git repositories fresh",
"global": true,
"repo": "imsky/git-fresh",