Skip to content

Commit ec1128c

Browse files
authored
Fix cargo update and push (#12)
- Add fetching and `main` switch so the updates are always on fresh sources. - Delete the remote branch if it exists, since it belongs to an old cargo-update invocation.
1 parent e78eda4 commit ec1128c

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

scripts/cargo-update-and-push.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,25 @@ if [[ -n "$(git status --porcelain)" ]]; then
88
exit 1
99
fi
1010

11+
git fetch
12+
branch_name=cargo-update
13+
14+
if [[ "$(git branch -r)" == *"github/${branch_name}"* ]]; then
15+
echo "Deleting remote branch..."
16+
git push github --delete "${branch_name}"
17+
fi
18+
19+
if [[ "$(git branch --show-current 2>&1 || :)" != "main" ]]; then
20+
echo "Switching to main..."
21+
git switch main
22+
git pull
23+
fi
24+
1125
cargo update
1226
cargo test
13-
if git rev-parse cargo-update 2>/dev/null >/dev/null; then
14-
git branch -D cargo-update
15-
fi
16-
git checkout -b cargo-update
27+
git checkout -B "${branch_name}"
1728
git commit -a -m 'Run cargo-update'
18-
git push --set-upstream github HEAD:cargo-update
29+
git push --set-upstream github HEAD:"${branch_name}"
1930

2031
pr_url=$(gh pr create \
2132
--title='Run cargo-update' \

0 commit comments

Comments
 (0)