13 Commits

Author SHA1 Message Date
Ivan Malopinsky c9b1f5c2e0 move install step to separate script, remove dependency on make 2015-11-27 13:11:06 -05:00
Ivan Malopinsky 85ee0683eb Merge pull request #56 from imsky/fresh-local-before-rebase
Rebase current branch before rebasing against remote root branch
2015-11-27 13:06:47 -05:00
Ivan Malopinsky c48f1d592a update usage in README, add install script 2015-11-27 13:06:14 -05:00
Ivan Malopinsky 15e62530d9 suppress error on invalid option 2015-11-27 13:03:46 -05:00
Ivan Malopinsky 8e81d7276e update usage 2015-11-27 12:59:18 -05:00
Ivan Malopinsky b6d35128c4 rebase local branch against its remote self before rebasing against remote root 2015-11-27 12:57:38 -05:00
Ivan Malopinsky 6dc3f6870d Merge pull request #54 from imsky/refactor/simplify-readme
simplify readme
2015-09-24 00:43:52 -04:00
Ivan Malopinsky 28f347b89d simplify readme 2015-09-24 00:43:43 -04:00
Ivan Malopinsky a94af51b11 Merge pull request #53 from imsky/bug/fix-syntax-error
fix syntax error
2015-09-24 00:41:53 -04:00
Ivan Malopinsky b11805e886 fix syntax error 2015-09-24 00:41:43 -04:00
Ivan Malopinsky 5327cb53c9 Merge pull request #52 from imsky/feature/delete-local-stale-only-flag
delete local stale only flag
2015-09-24 00:39:01 -04:00
Ivan Malopinsky c5db0306de bump version to 1.1 2015-09-24 00:38:32 -04:00
Ivan Malopinsky a16bc0b0c8 add option to remove only local stale branches, fix #50 2015-09-24 00:38:25 -04:00
5 changed files with 49 additions and 27 deletions
-2
View File
@@ -1,2 +0,0 @@
install:
cp git-fresh /usr/local/bin
+11 -11
View File
@@ -2,23 +2,23 @@
Keep your repo fresh with one command.
* Stashes your unstaged changes
* Updates local master to match remote, prunes stale branches
* Deletes stale local and remote branches with `-f` flag
* Merges remote master into current branch with `-m` flag
* Rebases current branch against remote master with `-r` flag
* Restores your stashed changes with `-s` flag
* Wipes the slate clean with `-F` flag
## Usage
```
Usage: git fresh [-fmrsF] [remote] [root]
Usage: git fresh [-fmrF] [-sl] [remote] [root]
By default, git-fresh will:
- 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
-s: Apply stashed changes after run
-F: Reset local root to remote root, wipe workspace
-s: Apply stashed changes after run
-l: Only delete local stale branches
remote: remote name, origin by default
root: root branch, master by default
```
@@ -29,7 +29,7 @@ root: root branch, master by default
1. Clone or download
2. `cd git-fresh`
3. `sudo make install`
3. `sudo ./install`
### Package
+31 -12
View File
@@ -1,15 +1,26 @@
#!/usr/bin/env bash
usage () {
echo "Usage: git fresh [-fmrsF] [remote] [root]"
echo "-f: Delete stale local and remote branches"
echo "-m: Merge remote root into current branch"
echo "-r: Rebase current branch against remote root"
echo "-s: Apply stashed changes after run"
echo "-F: Reset local root to remote root, wipe workspace"
echo "remote: remote name, origin by default"
echo "root: root branch, master by default"
exit 1;
cat << EOD
Usage: git fresh [-fmrF] [-sl] [remote] [root]
By default, git-fresh will:
- 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
-F: Reset local root to remote root, wipe workspace
-s: Apply stashed changes after run
-l: Only delete local stale branches
remote: remote name, origin by default
root: root branch, master by default
EOD
exit 0;
}
error () {
@@ -18,7 +29,7 @@ error () {
trap 'error $LINENO' ERR
while getopts "fmrsF" opt; do
while getopts ":fmrslF" opt; do
case $opt in
f)
FORCE_DELETE_STALE=true
@@ -32,11 +43,15 @@ while getopts "fmrsF" opt; do
s)
APPLY_STASH=true
;;
l)
DELETE_ONLY_LOCAL=true
;;
F)
FORCE_LOCAL_RESET=true
;;
*)
usage
break
;;
esac
done
@@ -56,6 +71,8 @@ if ! git diff-files --quiet; then
git stash save $STASH_STAMP
fi
git rebase $REMOTE $CURRENT
git checkout $ROOT > /dev/null 2>&1
if [[ "$FORCE_LOCAL_RESET" = true ]]; then
@@ -86,13 +103,15 @@ if [[ ! -z "${SMART_STALE// }" ]]; then
if [[ ! -z "${REMOTE_STALE// }" ]]; then
STALE_BRANCHES=true
if [[ "$FORCE_DELETE_STALE" = true ]]; then
echo -n $REMOTE_STALE | xargs git push $REMOTE --delete
if [[ "$DELETE_ONLY_LOCAL" != true ]]; then
echo -n $REMOTE_STALE | xargs git push $REMOTE --delete
fi
else
echo "Remote stale branches found:" $(echo -n $REMOTE_STALE | tr "\n" " ")
fi
fi
if [[ "$FORCE_DELETE_STALE" != true && $STALE_BRANCHES = true ]]; then
if [[ "$FORCE_DELETE_STALE" != true && "$STALE_BRANCHES" = true ]]; then
echo "Delete stale branches with: git fresh -f"
fi
fi
Executable
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
INSTALL_DIR=${INSTALL_DIR:-/usr/local/bin}
cp git-fresh $INSTALL_DIR
[ -e $INSTALL_DIR/git-fresh ] && echo git-fresh installed in $INSTALL_DIR
+2 -2
View File
@@ -1,8 +1,8 @@
{
"name": "git-fresh",
"version": "1.0.0",
"version": "1.2.0",
"description": "Utility to keep Git repositories fresh",
"global": true,
"repo": "imsky/git-fresh",
"install": "sudo make install"
"install": "sudo ./install"
}