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
dd1de371
Commit
dd1de371
authored
3 months ago
by
Montaño Sarria, Andres Felipe
Browse files
Options
Downloads
Patches
Plain Diff
Add script to replace tecnalia.com by tecnalia.dev at git repos
parent
61c3d491
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/set_dotdev_remotes.bash
+90
-0
90 additions, 0 deletions
scripts/set_dotdev_remotes.bash
with
90 additions
and
0 deletions
scripts/set_dotdev_remotes.bash
0 → 100644
+
90
−
0
View file @
dd1de371
#!/usr/bin/env bash
#
# Updates Git remote URLs by replacing 'tecnalia.com' with 'tecnalia.dev'
# in all Git repositories under the current directory
#
set
-euo
pipefail
# Makes the script safer
# Color definitions for better readability
readonly
GREEN
=
'\033[0;32m'
readonly
YELLOW
=
'\033[1;33m'
readonly
NC
=
'\033[0m'
# No Color
usage
()
{
echo
"Usage:
$(
basename
"
$0
"
)
[-d|--dry-run]"
echo
" -d, --dry-run Show changes without applying them"
exit
1
}
# Improved argument processing
dry_run
=
0
while
[[
$#
-gt
0
]]
;
do
case
$1
in
-d
|
--dry-run
)
dry_run
=
1
shift
;;
-h
|
--help
)
usage
;;
*
)
echo
"Error: Unknown option
$1
"
usage
;;
esac
done
# Function to process a repository
process_repo
()
{
local
repo_path
=
$1
local
remote
=
$2
local
remote_url
remote_url
=
$(
git
-C
"
${
repo_path
}
"
remote get-url
"
${
remote
}
"
)
if
[[
${
remote_url
}
==
*
"tecnalia.com"
*
]]
;
then
local
new_url
=
${
remote_url
//tecnalia.com/tecnalia.dev
}
echo
-e
"
${
YELLOW
}
Found deprecated remote URL
${
NC
}
"
echo
" Repository:
${
repo_path
}
"
echo
" Remote:
${
remote
}
"
echo
" Current URL:
${
remote_url
}
"
echo
" New URL:
${
new_url
}
"
if
[[
${
dry_run
}
-eq
0
]]
;
then
if
git
-C
"
${
repo_path
}
"
remote set-url
"
${
remote
}
"
"
${
new_url
}
"
;
then
echo
-e
"
${
GREEN
}
Replacement completed!
${
NC
}
"
else
echo
" Error updating remote URL"
>
&2
return
1
fi
fi
fi
}
main
()
{
local
count
=
0
local
errors
=
0
# Use process substitution for better handling of spaces in names
while
IFS
=
read
-r
-d
''
git_folder
;
do
repo_path
=
$(
dirname
"
$(
readlink
-f
"
${
git_folder
}
"
)
"
)
while
IFS
=
read
-r
remote
;
do
if
process_repo
"
${
repo_path
}
"
"
${
remote
}
"
;
then
((
count++
))
else
((
errors++
))
fi
done
< <
(
git
-C
"
${
repo_path
}
"
remote
)
done
< <
(
find
.
-name
'.git'
-type
d
-print0
)
# Final summary
echo
echo
"Execution summary:"
echo
" Repositories processed:
$count
"
[[
$errors
-gt
0
]]
&&
echo
" Errors found:
$errors
"
[[
$dry_run
-eq
1
]]
&&
echo
" (Dry-run mode: no changes were made)"
}
main
\ No newline at end of file
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