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 pr_branch="pr-${TIMESTAMP}" | ||||
| 	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 expanded_files=() | ||||
| 	local temp_branch_created=false | ||||
| 
 | ||||
| 	cleanup() { | ||||
| 		git checkout "${current_branch}" | ||||
| 		git checkout "${working_branch}" | ||||
| 
 | ||||
| 		if [ "$temp_branch_created" = true ]; then | ||||
| 			git checkout "${temp_branch}" -- "${expanded_files[@]}" | ||||
| @ -59,9 +59,6 @@ create_pr_from_files() { | ||||
| 		fi | ||||
| 	done | ||||
| 
 | ||||
| 	echo "Original files: ${files[@]}" | ||||
| 	echo "Expanded files: ${expanded_files[@]}" | ||||
| 
 | ||||
| 	# Check if there are any uncommitted changes | ||||
| 	if [ -n "$(git status -s)" ]; then | ||||
| 		# Only create temp branch and backup if there are uncommitted changes | ||||
| @ -77,7 +74,8 @@ create_pr_from_files() { | ||||
| 		temp_branch_created=true | ||||
| 	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 | ||||
| 		git checkout "$base_branch" || ( | ||||
| 			handle_error "Failed to checkout base branch" | ||||
| @ -101,19 +99,14 @@ create_pr_from_files() { | ||||
| 			return $? | ||||
| 		) | ||||
| 	else | ||||
| 		git checkout "$current_branch" -- "${expanded_files[@]}" || ( | ||||
| 		git checkout "$working_branch" -- "${expanded_files[@]}" || ( | ||||
| 			handle_error "Failed to restore specified files" | ||||
| 			return $? | ||||
| 		) | ||||
| 	fi | ||||
| 
 | ||||
| 	git add "${expanded_files[@]}" || ( | ||||
| 		handle_error "Failed to stage specified files" | ||||
| 		return $? | ||||
| 	) | ||||
| 
 | ||||
| 	# 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." | ||||
| 		return $? | ||||
| 	fi | ||||
| @ -145,6 +138,7 @@ create_pr_from_files() { | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| create_pr_from_commit() { | ||||
| 	local commit_hash="$1" | ||||
| 	local base_branch="${2:-development}" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user