Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scripts
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fabian.troller
scripts
Commits
22cee675
Commit
22cee675
authored
4 years ago
by
dylan.peiry
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parents
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+24
-0
24 additions, 0 deletions
.gitignore
gitcreate.sh
+69
-0
69 additions, 0 deletions
gitcreate.sh
with
93 additions
and
0 deletions
.gitignore
0 → 100644
+
24
−
0
View file @
22cee675
*
!*.*
!Makefile
*.o
*
!*.*
!Makefile
*.o
*
!*.*
!Makefile
*.o
*
!*.*
!Makefile
*.o
*
!*.*
!Makefile
*.o
*
!*.*
!Makefile
*.o
This diff is collapsed.
Click to expand it.
gitcreate.sh
0 → 100755
+
69
−
0
View file @
22cee675
#!/bin/bash
# Script to automatically create and init a repo on the specified gitlab instance
# Written by Dylan PEIRY (dylan.peiry@etu.hesge.ch
# Syntax : ./gitcreate.sh {username_aai} {public:true_or_false} {method:https_or_ssh}
ACCESS_TOKEN
=
"6HdtsLxS63D22EVPuzBX"
# methods of access
HTTPS
=
"https://gitedu.hesge.ch"
SSH
=
"ssh://git@ssh.hesge.ch:10572"
# Check the the access token is set
if
[[
-z
$ACCESS_TOKEN
]]
;
then
echo
'Please set your access token in the script.'
exit
fi
# Check the the visibility arg is specified
if
[[
$#
-lt
3
]]
;
then
echo
'The AAI username must be specified (firstname.lastname).'
echo
'The visibility level must be specified (true=public,false=private).'
echo
'The access method must be specified (https,ssh)'
exit
fi
# The name of the repository will be the name of the current directory
NAME
=
$(
basename
$PWD
)
USERNAME
=
$1
VISIBILITY
=
$2
ACCESS_METHOD
=
$3
echo
$ACCESS_METHOD
# Define the remote origin (url on which we will link the local repository)
REMOTE_ORIGIN
=
""
if
[[
$ACCESS_METHOD
==
"ssh"
]]
;
then
REMOTE_ORIGIN
=
"
$SSH
/
$USERNAME
/
$NAME
.git"
fi
if
[[
$ACCESS_METHOD
==
"https"
]]
;
then
REMOTE_ORIGIN
=
"
$HTTPS
/
$USERNAME
/
$NAME
.git"
fi
echo
$REMOTE_ORIGIN
# Call the api to create the repository with the specified name
RESPONSE
=
$(
curl
-X
POST
'https://gitedu.hesge.ch/api/v4/projects?private_token='
$ACCESS_TOKEN
''
\
-d
'{"name":"'
$NAME
'","path":"'
$NAME
'"}'
\
-H
"Content-Type: application/json"
\
-silent
)
# Look through the response to see if the name was taken by another repository
if
[[
$RESPONSE
==
*
"taken"
*
]]
;
then
echo
'A repository with the name ['
$NAME
'] already exists.'
exit
fi
# Create a .gitignore specific to a c program
touch
.gitignore
echo
"*"
>>
.gitignore
echo
"!*.*"
>>
.gitignore
echo
"!Makefile"
>>
.gitignore
echo
"*.o"
>>
.gitignore
# Initialize a local repository and push the files
git init
git remote add origin
$REMOTE_ORIGIN
git add
.
git commit
-m
"initial commit"
git push
-u
origin master
echo
'The repository was successfully created and the files were successfully pushed to it.'
\ 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