5 Commits

Author SHA1 Message Date
Ivan Malopinsky 7d0d33d32b Merge pull request #93 from imsky/main
Add support for main branch as root
2020-10-27 19:24:51 -04:00
Ivan Malopinsky b2fd270558 1.13.0 2020-10-27 19:23:55 -04:00
Ivan Malopinsky 3d7177e84c if only main branch exists, use that as root 2020-10-27 19:22:46 -04:00
Ivan Malopinsky 8bbe2a7d49 Merge pull request #92 from hrishabh23/ppwd
Change dir to repo root before making changes
2019-10-12 14:50:53 -04:00
Hrishabh 136a777d73 Change dir to repo root before making changes 2019-10-12 01:34:54 +05:30
3 changed files with 19 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017-2019 Ivan Malopinsky
Copyright (c) 2017-2020 Ivan Malopinsky
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+17 -1
View File
@@ -159,7 +159,14 @@ fi
ERR="could not get top-level-directory"
TOP_LEVEL_DIRECTORY=$(git rev-parse --show-toplevel)
REMOTE=${1:-origin}
ROOT=${2:-master}
ROOT_GUESS=master
if [[ -n $(git show-ref refs/heads/main) && -z $(git show-ref refs/heads/master) ]]; then
ROOT_GUESS=main
fi
ROOT=${2:-$ROOT_GUESS}
# Recover the root HEAD if it is missing or corrupt (e.g. master head reads "master")
recover_root () {
@@ -185,6 +192,9 @@ recover_root () {
recover_root
LAST_WORKING_DIRECTORY="$(pwd)"
cd "$TOP_LEVEL_DIRECTORY"
ERR="could not get current commit"
CURRENT=$(git rev-parse --abbrev-ref HEAD)
ERR=""
@@ -378,6 +388,12 @@ if ! git gc --auto --force; then
rm -rf "$TOP_LEVEL_DIRECTORY/.git/gc.log"
fi
if [[ -d "$LAST_WORKING_DIRECTORY" ]]; then
cd "$LAST_WORKING_DIRECTORY"
else
say "Previous working directory does not exist on the branch $ROOT"
fi
recover_root
ERR=""
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "git-fresh",
"version": "1.12.1",
"version": "1.13.0",
"description": "Utility to keep Git repositories fresh",
"global": true,
"repo": "imsky/git-fresh",