Skip to content

Commit

Permalink
fix: quiet and background git
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtabrams committed Jun 13, 2020
1 parent 19660a4 commit 8881b41
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.1] - 2020-06-12
### Fixed
- Make git commands quiet.
- Make git commands run asynchronously when possible.

## [0.3.0] - 2020-06-11
### Added
- Add rm command for easily removing old ideas.
Expand All @@ -19,7 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Created a script with the basic functionality.

[Unreleased]: https://github.com/adamtabrams/ideas/compare/0.3.0...HEAD
[Unreleased]: https://github.com/adamtabrams/ideas/compare/0.3.1...HEAD
[0.3.1]: https://github.com/adamtabrams/ideas/compare/0.3.0...0.3.1
[0.3.0]: https://github.com/adamtabrams/ideas/compare/0.2.0...0.3.0
[0.2.0]: https://github.com/adamtabrams/ideas/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/adamtabrams/ideas/releases/tag/0.1.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ View or edit existing ideas with `ideas` or `ideas NAME`

Remove unneeded ideas with `ideas rm`

Ideas automatically handles keeping your private repo synced.
Ideas automatically handles keeping your private repo synced
19 changes: 10 additions & 9 deletions ideas
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ rm_idea() {

prev_dir=$(pwd)
cd "$repo" || return 2
git pull
git pull -q

idea=$(select_idea "$repo")
[ ! "$idea" ] && return
Expand All @@ -46,12 +46,13 @@ rm_idea() {
printf "delete %s? (y/n): " "$idea"
read -r confirm
[ "$confirm" = y ] &&
echo "deleting $idea" >&2 &&
rm "$idea_file" &&
sed -n -i "" -e "/^- \[$idea\]($idea.md)$/!p" README.md &&
echo "deleted" >&2 &&
git add README.md "$idea_file" &&
git commit -m "removed $idea" &&
git push
git commit -q -m "removed $idea" &&
git push -q &&
echo "done" >&2

cd "$prev_dir" || return 2
}
Expand All @@ -63,15 +64,15 @@ add_idea() {

prev_dir=$(pwd)
cd "$repo" || return 2
git pull
git pull -q

idea_file="$repo/$idea.md"
[ -e "$idea_file" ] && echo "$idea_file already exists" >&2 && return 1

echo "- [$idea]($idea.md)" >> "$repo/README.md"
printf "## %s\n\n" "$idea" > "$idea_file"
${EDITOR:-vi} "$idea_file"
git add README.md "$idea_file" && git commit -m "added $idea" && git push
git add README.md "$idea_file" && git commit -q -m "added $idea" && git push -q &

cd "$prev_dir" || return 2
}
Expand Down Expand Up @@ -106,10 +107,10 @@ repo=$(get_repo) || exit 1

prev_dir=$(pwd)
cd "$repo" || exit 2
git pull

idea=$1
[ ! "$idea" ] && idea=$(select_idea "$repo")
[ "$idea" ] && git pull -q
[ ! "$idea" ] && { git pull -q & } && idea=$(select_idea "$repo")
[ ! "$idea" ] && exit

idea_file="$repo/$idea.md"
Expand All @@ -119,6 +120,6 @@ prev_mod=$(stat -qf "%Sc" "$idea_file")
${EDITOR:-vi} "$idea_file"

[ "$prev_mod" != "$(stat -qf "%Sc" "$idea_file")" ] &&
git add README.md "$idea_file" && git commit -m "modified $idea" && git push
git add "$idea_file" && git commit -q -m "modified $idea" && git push -q &

cd "$prev_dir" || exit 2

0 comments on commit 8881b41

Please sign in to comment.