Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Ask the user for the source url
echo "Hello, please enter the following information"
echo -n Git HTTPS url of the source code you want to copy :
read gitlabSourceREpo
echo "===> The url you want to copy is : " $gitlabSourceREpo
# Ask the user for the destination url
echo -n Git HTTPS destination url :
read gitlabDestREpo
echo "===> The source will be copied in : " $gitlabDestREpo
# Ask the user for the email
echo -n Email :
read gitlabEMail
echo "===> The email is : " $gitlabEMail
# Ask the user for the username
echo -n Username :
read gitlabUsername
echo "===> The username is : " $gitlabUsername
# Ask the user for the password
echo -n Password :
read -s gitlabPAssword
#We extract the correct url for the source
gitLabSourceWIthoutHttps=${gitlabSourceREpo:8}
#We get also thename of the repository
repoSourceName=${gitLabSourceWIthoutHttps##*/}
#We extract the correct url for the destination
gitLabDestinationWIthoutHttps=${gitlabDestREpo:8}
repoDestName=${gitLabDestinationWIthoutHttps##*/}
repoDEstNameWithoutExtension=${repoDestName%.*}
#We do the the clone of the first repository
git clone --bare https://$gitlabUsername:$gitlabPAssword@$gitLabSourceWIthoutHttps
#We move in the folder containing all of the information about the old repository
cd $repoSourceName
git push --mirror https://$gitlabUsername:$gitlabPAssword@$gitLabDestinationWIthoutHttps
#We remove the temporary local repository
cd ..
rm -rf $repoSourceName
#We clone the new repository
git clone https://$gitlabUsername:$gitlabPAssword@$gitLabDestinationWIthoutHttps
#We copy the gitlab.yml file into the new folder, commit and push
cd $repoDEstNameWithoutExtension
cp /usr/bmap/.gitlab-ci.yml .
echo "We set the git configuration: "
sudo git config --system --unset credential.helper
sudo git config --system credential.helper store
sudo git config --global user.email $gitlabEMail
sudo git config --global user.name $gitlabUsername
git add .gitlab-ci.yml
git commit -m "gitlab-ci.yml added"
git push https://$gitlabUsername:$gitlabPAssword@$gitLabDestinationWIthoutHttps --all