Update roles/home/scripts/commits.sh
This commit is contained in:
parent
a62e0f2869
commit
165fa5f3ce
@ -3,13 +3,13 @@ create_pr_from_files() {
|
|||||||
local temp_branch="pr-${TIMESTAMP}-temp"
|
local temp_branch="pr-${TIMESTAMP}-temp"
|
||||||
local pr_branch="pr-${TIMESTAMP}"
|
local pr_branch="pr-${TIMESTAMP}"
|
||||||
local base_branch="development"
|
local base_branch="development"
|
||||||
local current_branch=$(git rev-parse --abbrev-ref HEAD)
|
local working_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
local files=()
|
local files=()
|
||||||
local expanded_files=()
|
local expanded_files=()
|
||||||
local temp_branch_created=false
|
local temp_branch_created=false
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
git checkout "${current_branch}"
|
git checkout "${working_branch}"
|
||||||
|
|
||||||
if [ "$temp_branch_created" = true ]; then
|
if [ "$temp_branch_created" = true ]; then
|
||||||
git checkout "${temp_branch}" -- "${expanded_files[@]}"
|
git checkout "${temp_branch}" -- "${expanded_files[@]}"
|
||||||
@ -59,9 +59,6 @@ create_pr_from_files() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Original files: ${files[@]}"
|
|
||||||
echo "Expanded files: ${expanded_files[@]}"
|
|
||||||
|
|
||||||
# Check if there are any uncommitted changes
|
# Check if there are any uncommitted changes
|
||||||
if [ -n "$(git status -s)" ]; then
|
if [ -n "$(git status -s)" ]; then
|
||||||
# Only create temp branch and backup if there are uncommitted changes
|
# Only create temp branch and backup if there are uncommitted changes
|
||||||
@ -77,7 +74,8 @@ create_pr_from_files() {
|
|||||||
temp_branch_created=true
|
temp_branch_created=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Switch to base branch and create temporary branch
|
# Get current branch and switch to base branch if needed
|
||||||
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
if [ "$current_branch" != "$base_branch" ]; then
|
if [ "$current_branch" != "$base_branch" ]; then
|
||||||
git checkout "$base_branch" || (
|
git checkout "$base_branch" || (
|
||||||
handle_error "Failed to checkout base branch"
|
handle_error "Failed to checkout base branch"
|
||||||
@ -101,19 +99,14 @@ create_pr_from_files() {
|
|||||||
return $?
|
return $?
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
git checkout "$current_branch" -- "${expanded_files[@]}" || (
|
git checkout "$working_branch" -- "${expanded_files[@]}" || (
|
||||||
handle_error "Failed to restore specified files"
|
handle_error "Failed to restore specified files"
|
||||||
return $?
|
return $?
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git add "${expanded_files[@]}" || (
|
|
||||||
handle_error "Failed to stage specified files"
|
|
||||||
return $?
|
|
||||||
)
|
|
||||||
|
|
||||||
# Verify files were staged
|
# Verify files were staged
|
||||||
if [ -z "$(git diff --cached --name-only)" ]; then
|
if [ -z "$(git diff --staged)" ]; then
|
||||||
handle_error "No files were staged. Aborting PR creation."
|
handle_error "No files were staged. Aborting PR creation."
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
@ -145,6 +138,7 @@ create_pr_from_files() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
create_pr_from_commit() {
|
create_pr_from_commit() {
|
||||||
local commit_hash="$1"
|
local commit_hash="$1"
|
||||||
local base_branch="${2:-development}"
|
local base_branch="${2:-development}"
|
||||||
|
Loading…
Reference in New Issue
Block a user