Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Development_Environment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Montaño Sarria, Andres Felipe
Development_Environment
Commits
3ddfe98f
Commit
3ddfe98f
authored
3 months ago
by
Montaño Sarria, Andres Felipe
Browse files
Options
Downloads
Patches
Plain Diff
Add .rosinstall and .repos to substitution options
parent
4ef4fbaa
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/.vscode/launch.json
+8
-0
8 additions, 0 deletions
config/.vscode/launch.json
scripts/set_dotdev_tecnalia.sh
+215
-0
215 additions, 0 deletions
scripts/set_dotdev_tecnalia.sh
with
223 additions
and
0 deletions
config/.vscode/launch.json
+
8
−
0
View file @
3ddfe98f
...
@@ -15,6 +15,14 @@
...
@@ -15,6 +15,14 @@
"launch_rviz:=false"
"launch_rviz:=false"
],
],
"type"
:
"ros"
"type"
:
"ros"
},
{
"type"
:
"bashdb"
,
"request"
:
"launch"
,
"name"
:
"Bash simple"
,
"cwd"
:
"${workspaceFolder}"
,
"program"
:
"${file}"
,
"terminalKind"
:
"integrated"
}
}
]
]
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
scripts/set_dotdev_
remotes
.sh
→
scripts/set_dotdev_
tecnalia
.sh
+
215
−
0
View file @
3ddfe98f
#!/usr/bin/env bash
#!/usr/bin/env bash
#
#
# Updates Git remote URLs by replacing 'tecnalia.com' with 'tecnalia.dev'
# Updates URLs by replacing 'tecnalia.com' with 'tecnalia.dev' in:
# recursively in all Git repositories under the current directory
# - 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
# Color definitions for better readability
readonly
GREEN
=
'\033[0;32m'
readonly
GREEN
=
'\033[0;32m'
...
@@ -13,11 +16,15 @@ readonly BLUE='\033[0;34m'
...
@@ -13,11 +16,15 @@ readonly BLUE='\033[0;34m'
readonly
NC
=
'\033[0m'
# No Color
readonly
NC
=
'\033[0m'
# No Color
usage
()
{
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
"Options:"
echo
" -d, --dry-run Show changes without applying them"
echo
" -d, --dry-run Show changes without applying them"
echo
" -m, --max-depth N Maximum depth for recursive search (default: unlimited)"
echo
" -m, --max-depth N Maximum depth for recursive search (default: unlimited)"
echo
" Use 1 for current directory only"
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"
echo
" -h, --help Show this help message"
exit
1
exit
1
}
}
...
@@ -25,6 +32,7 @@ usage() {
...
@@ -25,6 +32,7 @@ usage() {
# Improved argument processing
# Improved argument processing
dry_run
=
0
dry_run
=
0
max_depth
=
""
max_depth
=
""
file_type
=
"all"
while
[[
$#
-gt
0
]]
;
do
while
[[
$#
-gt
0
]]
;
do
case
$1
in
case
$1
in
...
@@ -41,6 +49,15 @@ while [[ $# -gt 0 ]]; do
...
@@ -41,6 +49,15 @@ while [[ $# -gt 0 ]]; do
usage
usage
fi
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
)
-h
|
--help
)
usage
usage
;;
;;
...
@@ -73,42 +90,124 @@ process_repo() {
...
@@ -73,42 +90,124 @@ process_repo() {
if
[[
${
dry_run
}
-eq
0
]]
;
then
if
[[
${
dry_run
}
-eq
0
]]
;
then
if
git
-C
"
${
repo_path
}
"
remote set-url
"
${
remote
}
"
"
${
new_url
}
"
;
then
if
git
-C
"
${
repo_path
}
"
remote set-url
"
${
remote
}
"
"
${
new_url
}
"
;
then
echo
-e
"
${
GREEN
}
Replacement completed!
${
NC
}
"
echo
-e
"
${
GREEN
}
Replacement completed!
${
NC
}
"
return
0
else
else
echo
" Error updating remote URL"
>
&2
echo
" Error updating remote URL"
>
&2
return
1
return
1
fi
fi
fi
fi
return
0
fi
fi
return
2
# No changes needed
}
}
main
()
{
# Function to process .rosinstall and .repos files
local
count
=
0
process_config_file
()
{
local
errors
=
0
local
file
=
$1
local
repos_found
=
0
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
# Create temporary file in the same directory to preserve permissions
while
IFS
=
read
-r
-d
''
git_folder
||
[
-n
"
$git_folder
"
]
;
do
temp_file
=
"
${
file
}
.tmp"
((
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
if
[[
-f
"
$file
"
]]
;
then
if
process_repo
"
${
repo_path
}
"
"
${
remote
}
"
;
then
if
grep
-q
"tecnalia.com"
"
$file
"
;
then
((
count++
))
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
else
((
errors++
))
echo
"Changes that would be made:"
sed
's/tecnalia.com/tecnalia.dev/g'
"
$file
"
| diff
"
$file
"
-
||
true
changes_made
=
1
fi
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
# Final summary
echo
echo
echo
"Execution summary:"
echo
"Execution summary:"
echo
" Git repositories found:
$repos_found
"
if
[[
$file_type
==
"git"
||
$file_type
==
"all"
]]
;
then
echo
" Repositories processed:
$count
"
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
"
[[
$errors
-gt
0
]]
&&
echo
" Errors found:
$errors
"
[[
$dry_run
-eq
1
]]
&&
echo
" (Dry-run mode: no changes were made)"
[[
$dry_run
-eq
1
]]
&&
echo
" (Dry-run mode: no changes were made)"
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment