added
This commit is contained in:
9
fun.sh
9
fun.sh
@@ -1,9 +0,0 @@
|
|||||||
#! /usr/bin/env bash
|
|
||||||
#
|
|
||||||
#for branch in $(git for-each-ref --format='%(refname)' refs/heads/); do
|
|
||||||
# echo "${branch/'refs/heads/'/''}"
|
|
||||||
#done
|
|
||||||
|
|
||||||
function test() {
|
|
||||||
git for-each-ref --format='%(refname)' refs/heads/
|
|
||||||
}
|
|
||||||
15
func.sh
Normal file
15
func.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
function sub_akt() {
|
||||||
|
#$1 ist Branch
|
||||||
|
#$2 neue URLD
|
||||||
|
new_sub_url="$2"
|
||||||
|
pro_be_cut=${new_sub_url##*/}
|
||||||
|
sub_name=${pro_be_cut::-4}
|
||||||
|
echo "git checkout $1"
|
||||||
|
echo "git submodule set-url $sub_name $new_sub_url"
|
||||||
|
echo "git submodule update --init --recursive --remote $sub_name"
|
||||||
|
echo "git add .gitmodules"
|
||||||
|
echo "git commit -m 'Submodul aktualisiert'"
|
||||||
|
echo "git push"
|
||||||
|
}
|
||||||
37
main.sh
37
main.sh
@@ -1,33 +1,46 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
#for branch in $(git for-each-ref --format='%(refname)' refs/heads/); do
|
|
||||||
# echo "${branch/'refs/heads/'/''}"
|
|
||||||
#done
|
|
||||||
|
|
||||||
clone_work_dir="/home/jonnybravo/workdir"
|
clone_work_dir="/home/jonnybravo/workdir"
|
||||||
script_folder="$(pwd)"
|
script_folder="$(pwd)"
|
||||||
echo $script_folder
|
logfile=/home/jonnybravo/sysint-migration-submodule.log
|
||||||
|
source "func.sh"
|
||||||
|
|
||||||
#create_clone_Folder
|
#create_clone_Folder
|
||||||
if [ ! -d $clone_work_dir ]
|
if [ ! -d $clone_work_dir ]
|
||||||
then
|
then
|
||||||
mkdir -p $clone_work_dir
|
mkdir -p $clone_work_dir
|
||||||
|
if [ $? -eq 0 ]; then echo " $(date '+%Y-%m-%d %H:%M:%S') - $clone_work_dir wurde angelegt!" >> $logfile
|
||||||
|
else echo "ERROR - $(date '+%Y-%m-%d %H:%M:%S') - $clone_work_dir konnte NICHT angelgt werden ERROR "; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while IFS="," read -r git_url project_name
|
while IFS="," read -r git_url new_sub_url
|
||||||
do
|
do
|
||||||
|
pro_be_cut=${git_url##*/}
|
||||||
|
project_name=${pro_be_cut::-4}
|
||||||
clone_folder="$clone_work_dir/$project_name"
|
clone_folder="$clone_work_dir/$project_name"
|
||||||
if [ -d $clone_work_dir ]
|
if [ -d $clone_folder ]
|
||||||
then
|
then
|
||||||
echo "Verzechnis $clone_work_dir existiert bereits"
|
echo "Verzechnis $clone_folder existiert bereits"
|
||||||
else
|
else
|
||||||
git clone $git_url $clone_folder
|
git clone $git_url $clone_folder
|
||||||
fi
|
if [ $? -eq 0 ]; then echo "INFO - $(date '+%Y-%m-%d %H:%M:%S') - $git_url wurde geclont !" >> $logfile
|
||||||
cd $clone_folder
|
else echo "ERROR - $(date '+%Y-%m-%d %H:%M:%S') - $git_url konnte NICHT geclont werden ERROR "; fi
|
||||||
|
fi
|
||||||
|
cd $clone_folder
|
||||||
for branch in $(git for-each-ref --format='%(refname)' refs/heads/)
|
for branch in $(git for-each-ref --format='%(refname)' refs/heads/)
|
||||||
do
|
do
|
||||||
git_pro_branch="${branch/'refs/heads/'/''}"
|
git_pro_branch="${branch/'refs/heads/'/''}"
|
||||||
echo "$project_name as $git_pro_branch"
|
echo "$project_name as $git_pro_branch"
|
||||||
|
sub_akt $git_pro_branch $new_sub_url
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then echo "INFO - $(date '+%Y-%m-%d %H:%M:%S') - konnte $new_sub_url auf $git_pro_branch aktualisieren" >> $logfile
|
||||||
|
else echo "ERROR - $(date '+%Y-%m-%d %H:%M:%S') - konnte NICHT $new_sub_url auf $git_pro_branch aktualisieren "; fi
|
||||||
|
|
||||||
done
|
done
|
||||||
cd $script_folder
|
cd $script_folder
|
||||||
|
rm -rf "$clone_folder"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then echo "INFO - $(date '+%Y-%m-%d %H:%M:%S') - $clone_folder wurde gelöscht !" >> $logfile
|
||||||
|
else echo "ERROR - $(date '+%Y-%m-%d %H:%M:%S') - $colne_folder konnte NICHT gelöscht werden ERROR "; fi
|
||||||
|
|
||||||
done < <(tail -n +2 project.csv)
|
done < <(tail -n +2 project.csv)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
git_url,project_name,
|
git_url,new_sub_url,
|
||||||
https://gitea.schlaubistechtalk.de/t4m/docker_gitlab.git,docker_gitlab,
|
https://gitea.schlaubistechtalk.de/t4m/docker_gitlab.git, https://gitea.schlaubistechtalk.de/t4m/win_ps_hidden_files.git,
|
||||||
https://gitea.schlaubistechtalk.de/t4m/win_ps_hidden_files.git,win_ps_hidden_files,
|
https://gitea.schlaubistechtalk.de/t4m/win_ps_hidden_files.git,https://gitea.schlaubistechtalk.de/t4m/docker_gitlab.git,
|
||||||
|
|||||||
|
Reference in New Issue
Block a user