feat: Add push command to automate pushing changes to all remotes
This commit is contained in:
parent
a087ffe7b0
commit
63a1948551
29
bin/actions/push.sh
Executable file
29
bin/actions/push.sh
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||||
|
|
||||||
|
# Push all changes from $HOME/dotfiles to ALL remotes in $HOME/dotfiles/.git/config
|
||||||
|
push_all() {
|
||||||
|
# Get all remotes from the .git/config file
|
||||||
|
remotes=($(cat $HOME/dotfiles/.git/config | grep url | awk '{print $3}'))
|
||||||
|
|
||||||
|
printfe "%s\n" "cyan" "Pushing all changes to all remotes..."
|
||||||
|
|
||||||
|
# For each remote, push all changes
|
||||||
|
for remote in $remotes; do
|
||||||
|
printfe "%s" "green" " - Pushing to ["
|
||||||
|
printfe "%s" "blue" "$remote"
|
||||||
|
printfe "%s\n" "green" "]..."
|
||||||
|
|
||||||
|
result=$(git -C $HOME/dotfiles push $remote 2>&1)
|
||||||
|
|
||||||
|
# If the push failed, print an error
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
printfe "%s\n" "red" " - Failed to push to $remote:"
|
||||||
|
printfe "%s\n" "red" " $result"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
push_all
|
8
bin/dotf
8
bin/dotf
@ -23,6 +23,10 @@ secrets() {
|
|||||||
$HOME/dotfiles/bin/actions/secrets.sh $@
|
$HOME/dotfiles/bin/actions/secrets.sh $@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
push() {
|
||||||
|
$HOME/dotfiles/bin/actions/push.sh $@
|
||||||
|
}
|
||||||
|
|
||||||
ensure_git_hooks() {
|
ensure_git_hooks() {
|
||||||
# If ~/dotfiles/.git/hooks is a symlink, skip this
|
# If ~/dotfiles/.git/hooks is a symlink, skip this
|
||||||
if [[ -L ~/dotfiles/.git/hooks ]]; then
|
if [[ -L ~/dotfiles/.git/hooks ]]; then
|
||||||
@ -50,6 +54,10 @@ case $1 in
|
|||||||
logo
|
logo
|
||||||
update $@
|
update $@
|
||||||
;;
|
;;
|
||||||
|
"push")
|
||||||
|
logo continue
|
||||||
|
push $@
|
||||||
|
;;
|
||||||
"status")
|
"status")
|
||||||
logo continue
|
logo continue
|
||||||
status $@
|
status $@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user