Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
1 result

Target

Select target project
  • andres.montano/development_environment
1 result
Select Git revision
  • main
1 result
Show changes
Commits on Source (2)
......@@ -15,6 +15,14 @@
"launch_rviz:=false"
],
"type": "ros"
},
{
"type": "bashdb",
"request": "launch",
"name": "Bash simple",
"cwd": "${workspaceFolder}",
"program": "${file}",
"terminalKind": "integrated"
}
]
}
\ No newline at end of file
# List with the additional libraries to install in devenv image
#
# bat
# https://github.com/sharkdp/bat/releases/download/v0.25.0/bat-musl_0.25.0_musl-linux-amd64.deb
#
# ripgrep
# https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep_14.1.1-1_amd64.deb
#
# lsd-musl
# https://api.github.com/repos/lsd-rs/lsd/releases/latest
# curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
......
#!/usr/bin/env bash
#
# Updates Git remote URLs by replacing 'tecnalia.com' with 'tecnalia.dev'
# recursively in all Git repositories under the current directory
# Updates URLs by replacing 'tecnalia.com' with 'tecnalia.dev' in:
# - Git repository remotes
# - .rosinstall files
# - .repos files
#
set -e pipefail # Keep error handling but remove -u flag
# set -e
# set -euo pipefail
# Color definitions for better readability
readonly GREEN='\033[0;32m'
......@@ -13,11 +16,15 @@ readonly BLUE='\033[0;34m'
readonly NC='\033[0m' # No Color
usage() {
echo "Usage: $(basename "$0") [-d|--dry-run] [-m|--max-depth N]"
echo "Usage: $(basename "$0") [-d|--dry-run] [-m|--max-depth N] [-t|--type TYPE]"
echo "Options:"
echo " -d, --dry-run Show changes without applying them"
echo " -m, --max-depth N Maximum depth for recursive search (default: unlimited)"
echo " Use 1 for current directory only"
echo " -t, --type TYPE Specify which types of files to process:"
echo " git - only process Git remotes"
echo " repos - only process .rosinstall and .repos files"
echo " all - process all files (default)"
echo " -h, --help Show this help message"
exit 1
}
......@@ -25,6 +32,7 @@ usage() {
# Improved argument processing
dry_run=0
max_depth=""
file_type="all"
while [[ $# -gt 0 ]]; do
case $1 in
......@@ -41,6 +49,15 @@ while [[ $# -gt 0 ]]; do
usage
fi
;;
-t|--type)
if [[ "${2:-}" =~ ^(git|repos|all)$ ]]; then
file_type=$2
shift 2
else
echo "Error: --type must be 'git', 'repos', or 'all'"
usage
fi
;;
-h|--help)
usage
;;
......@@ -73,42 +90,124 @@ process_repo() {
if [[ ${dry_run} -eq 0 ]]; then
if git -C "${repo_path}" remote set-url "${remote}" "${new_url}"; then
echo -e " ${GREEN}Replacement completed!${NC}"
return 0
else
echo " Error updating remote URL" >&2
return 1
fi
fi
return 0
fi
return 2 # No changes needed
}
main() {
local count=0
local errors=0
local repos_found=0
# Function to process .rosinstall and .repos files
process_config_file() {
local file=$1
local file_type=$2
local changes_made=0
local temp_file
echo -e "${BLUE}Starting recursive search for Git repositories...${NC}"
echo -e "${BLUE}Processing ${file_type} file: ${file}${NC}"
# Use process substitution for better handling of spaces in names
while IFS= read -r -d '' git_folder || [ -n "$git_folder" ]; do
((repos_found++))
repo_path=$(dirname "$(readlink -f "${git_folder}")")
echo -e "${BLUE}Processing repository: ${repo_path}${NC}"
# Create temporary file in the same directory to preserve permissions
temp_file="${file}.tmp"
while IFS= read -r remote || [ -n "$remote" ]; do
if process_repo "${repo_path}" "${remote}"; then
((count++))
if [[ -f "$file" ]]; then
if grep -q "tecnalia.com" "$file"; then
echo -e "${YELLOW}Found deprecated URLs in: ${file}${NC}"
if [[ ${dry_run} -eq 0 ]]; then
# Create backup
cp "$file" "${file}.bak"
# Replace URLs
sed 's/tecnalia.com/tecnalia.dev/g' "$file" > "$temp_file"
# Show diff
echo "Changes made:"
diff "$file" "$temp_file" || true
# Replace original file
mv "$temp_file" "$file"
echo -e " ${GREEN}Replacement completed!${NC}"
echo " Backup saved as: ${file}.bak"
changes_made=1
else
((errors++))
echo "Changes that would be made:"
sed 's/tecnalia.com/tecnalia.dev/g' "$file" | diff "$file" - || true
changes_made=1
fi
done < <(git -C "${repo_path}" remote 2>/dev/null || echo "")
fi
fi
done < <(find . ${max_depth:-} -name '.git' -type d -print0 2>/dev/null || echo "")
# Clean up temporary file if it exists
[[ -f "$temp_file" ]] && rm "$temp_file"
return $changes_made
}
main() {
local git_count=0
local rosinstall_count=0
local repos_count=0
local errors=0
local repos_found=0
local config_files_found=0
echo -e "${BLUE}Starting recursive search for specified file types...${NC}"
# Process Git repositories
if [[ $file_type == "git" || $file_type == "all" ]]; then
echo -e "${BLUE}Looking for Git repositories...${NC}"
while IFS= read -r -d '' git_folder || [ -n "$git_folder" ]; do
((repos_found++))
repo_path=$(dirname "$(readlink -f "${git_folder}")")
echo -e "${BLUE}Processing repository: ${repo_path}${NC}"
while IFS= read -r remote || [ -n "$remote" ]; do
result=$(process_repo "${repo_path}" "${remote}")
case $? in
0) ((git_count++));;
1) ((errors++));;
esac
done < <(git -C "${repo_path}" remote 2>/dev/null || echo "")
done < <(find . ${max_depth:-} -name '.git' -type d -print0 2>/dev/null || echo "")
fi
# Process config files
if [[ $file_type == "repos" || $file_type == "all" ]]; then
echo -e "${BLUE}Looking for configuration files...${NC}"
# Process .rosinstall files
while IFS= read -r -d '' rosinstall_file || [ -n "$rosinstall_file" ]; do
((config_files_found++))
if process_config_file "$rosinstall_file" ".rosinstall"; then
((rosinstall_count++))
fi
done < <(find . ${max_depth:-} -name '*.rosinstall' -type f -print0 2>/dev/null || echo "")
# Process .repos files
while IFS= read -r -d '' repos_file || [ -n "$repos_file" ]; do
((config_files_found++))
if process_config_file "$repos_file" ".repos"; then
((repos_count++))
fi
done < <(find . ${max_depth:-} -name '*.repos' -type f -print0 2>/dev/null || echo "")
fi
# Final summary
echo
echo "Execution summary:"
echo " Git repositories found: $repos_found"
echo " Repositories processed: $count"
if [[ $file_type == "git" || $file_type == "all" ]]; then
echo " Git repositories found: $repos_found"
echo " Git remotes updated: $git_count"
fi
if [[ $file_type == "config" || $file_type == "all" ]]; then
echo " Configuration files found: $config_files_found"
echo " .rosinstall files updated: $rosinstall_count"
echo " .repos files updated: $repos_count"
fi
[[ $errors -gt 0 ]] && echo " Errors found: $errors"
[[ $dry_run -eq 1 ]] && echo " (Dry-run mode: no changes were made)"
}
......