Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Iliya Manolov
slapos.toolbox
Commits
7a9ce4ff
Commit
7a9ce4ff
authored
Feb 29, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change git repository management UI
parent
577b9352
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
28 deletions
+73
-28
slapos/runner/gittools.py
slapos/runner/gittools.py
+23
-13
slapos/runner/templates/cloneRepository.html
slapos/runner/templates/cloneRepository.html
+41
-11
slapos/runner/templates/manageProject.html
slapos/runner/templates/manageProject.html
+8
-3
slapos/runner/templates/projectDiff.html
slapos/runner/templates/projectDiff.html
+1
-1
No files found.
slapos/runner/gittools.py
View file @
7a9ce4ff
...
...
@@ -19,9 +19,12 @@ class Popen(subprocess.Popen):
self
.
stdin
.
flush
()
self
.
stdin
.
close
()
self
.
stdin
=
None
def
cloneRepo
(
data
):
workDir
=
data
[
'path'
]
if
not
workDir
:
return
jsonify
(
code
=
0
,
result
=
"Can not create project folder: Permission Denied"
)
code
=
0
json
=
""
try
:
...
...
@@ -36,7 +39,7 @@ def cloneRepo(data):
config_writer
.
set_value
(
"user"
,
"email"
,
data
[
"email"
])
code
=
1
except
Exception
,
e
:
json
=
s
tr
(
e
)
json
=
s
afeResult
(
str
(
e
)
)
if
os
.
path
.
exists
(
workDir
):
shutil
.
rmtree
(
workDir
)
return
jsonify
(
code
=
code
,
result
=
json
)
...
...
@@ -52,7 +55,7 @@ def gitStatus(project):
isdirty
=
repo
.
is_dirty
(
untracked_files
=
True
)
code
=
1
except
Exception
,
e
:
json
=
s
tr
(
e
)
json
=
s
afeResult
(
str
(
e
)
)
return
jsonify
(
code
=
code
,
result
=
json
,
branch
=
branch
,
dirty
=
isdirty
)
def
switchBranch
(
project
,
name
):
...
...
@@ -65,23 +68,26 @@ def switchBranch(project, name):
if
name
==
current_branch
:
json
=
"This is already your active branch for this project"
else
:
json
=
"Error: Can not found branch '"
+
name
+
"'"
git
=
repo
.
git
git
.
checkout
(
name
)
code
=
1
except
Exception
,
e
:
json
=
s
tr
(
e
)
json
=
s
afeResult
(
str
(
e
)
)
return
jsonify
(
code
=
code
,
result
=
json
)
def
createBranch
(
project
,
nam
e
):
def
addBranch
(
project
,
name
,
onlyCheckout
=
Fals
e
):
code
=
0
json
=
""
try
:
repo
=
Repo
(
project
)
git
=
repo
.
git
git
.
checkout
(
'-b'
,
name
)
if
not
onlyCheckout
:
git
.
checkout
(
'-b'
,
name
)
else
:
git
.
checkout
(
name
)
code
=
1
except
Exception
,
e
:
json
=
s
tr
(
e
)
json
=
s
afeResult
(
str
(
e
)
)
return
jsonify
(
code
=
code
,
result
=
json
)
def
getDiff
(
project
):
...
...
@@ -92,7 +98,7 @@ def getDiff(project):
current_branch
=
repo
.
active_branch
.
name
result
=
git
.
diff
(
current_branch
)
except
Exception
,
e
:
result
=
s
tr
(
e
)
result
=
s
afeResult
(
str
(
e
)
)
return
result
def
gitPush
(
project
,
msg
):
...
...
@@ -103,7 +109,7 @@ def gitPush(project, msg):
repo
=
Repo
(
project
)
if
repo
.
is_dirty
:
git
=
repo
.
git
current_branch
=
repo
.
active_branch
.
name
current_branch
=
repo
.
active_branch
.
name
#add file to be commited
files
=
repo
.
untracked_files
for
f
in
files
:
...
...
@@ -120,7 +126,7 @@ def gitPush(project, msg):
except
Exception
,
e
:
if
undo_commit
:
git
.
reset
(
"HEAD~"
)
#undo previous commit
json
=
s
tr
(
e
)
json
=
s
afeResult
(
str
(
e
)
)
return
jsonify
(
code
=
code
,
result
=
json
)
def
gitPull
(
project
):
...
...
@@ -133,5 +139,9 @@ def gitPull(project):
git
.
pull
()
code
=
1
except
Exception
,
e
:
result
=
str
(
e
)
return
jsonify
(
code
=
code
,
result
=
result
)
\ No newline at end of file
result
=
safeResult
(
str
(
e
))
return
jsonify
(
code
=
code
,
result
=
result
)
def
safeResult
(
result
):
regex
=
re
.
compile
(
"(https:
\
/
\
/)([
\
w
\
d
\
._-]+:[
\
w
\
d
\
._-]+)
\
@([
\
S]+
\
s)
"
, re.VERBOSE)
return regex.sub(r'
\
1
\
3
', result)
\ No newline at end of file
slapos/runner/templates/cloneRepository.html
View file @
7a9ce4ff
...
...
@@ -8,11 +8,11 @@
{% endblock %}
{% block body %}
<
div
id=
"repository"
>
<
h2>
Clone your repository into the workspace
</h2><br/
>
<
h2
class=
'title'
>
Clone your repository into the workspace
</h2><br/
>
<
div
id=
"repository"
style=
"margin-left:40px;"
>
<label
for=
'name'
>
Project name*:
</label>
<input
type=
"text"
name=
"name"
id=
"name"
size=
'20'
value=
"Enter the project name..."
/>
<label
for=
'repo'
>
url
:
</label>
<label
for=
'repo'
>
url
*:
</label>
<input
type=
"text"
name=
"repo"
id=
"repo"
size=
'25'
value=
"Enter the url of your repository..."
/><br/>
<label
for=
'user'
>
Your name:
</label>
<input
type=
"text"
name=
"user"
id=
"user"
size=
'20'
value=
"Enter your name..."
/>
...
...
@@ -21,16 +21,46 @@
<input
type=
"hidden"
name=
"workdir"
id=
"workdir"
value=
"{{workDir}}"
/>
<button
class=
"button"
id=
"clone"
>
clone
</button>
<img
class=
"waitting"
id=
"imgwaitting"
src=
"{{ url_for('static', filename='images/waiting.gif') }}"
alt=
""
/>
<br/><br/>
<br/>
<br/><br/>
</div>
<h2>
You can use this public key for Git SSH
</h2>
<textarea
class=
"public_key"
readonly
>
{{public_key}}
</textarea>
<p>
to use git with https, please enter your repository url like this
<strong><i>
https://your_login:your_password@your_repository
</i></strong></p><br/><br/>
<h2>
Set your Security Mode
</h2>
<div
class=
"clone-box-right"
>
<div
style=
"background:#fff; padding:10px; min-height:100px; font-size:14px;"
>
<div
id=
"box0"
>
<h2>
Clone Repository without using HTTPS and SSH
</h2><br/>
<p>
Choose this mode if you have login and password for the repository and you if you don't have the possibility to
use SSH authentication. Otherwise use your public key or your login and password to clone your project. Note
that, with readonly mode you can not be able to push your changes.
</p>
<br/>
</div>
<div
id=
"box1"
style=
"display:none"
>
<h2>
You can use this public key to setup your repository
</h2><br/>
<textarea
class=
"public_key"
readonly
>
{{public_key}}
</textarea>
</div>
<div
id=
"box2"
style=
"display:none;"
>
<h2>
Enter your username and password for https authentication access
</h2><br/>
<div
style=
"margin-left:80px; margin-bottom:20px;"
>
<label
for=
'username'
>
Your username:
</label>
<input
type=
"text"
name=
"username"
id=
"username"
size=
'20'
value=
"Enter your username..."
/><br/><br/>
<label
for=
'password'
>
Your password:
</label>
<input
type=
"password"
name=
"password"
id=
"password"
size=
'20'
value=
""
class=
"idleField"
/>
</div>
<p></p>
</div>
</div>
</div>
<div
class=
"clone-box-left"
>
<ul
id=
"modelist"
>
<li
class=
"checked"
><input
type=
"radio"
name=
"security"
id=
"nothing"
value=
"nothing"
/><label
for=
"nothing"
>
ReadOnly
</label></li>
<li><input
type=
"radio"
name=
"security"
id=
"ssh"
value=
"SSH"
checked
/><label
for=
"ssh"
>
SSH Mode
</label></li>
<li><input
type=
"radio"
name=
"security"
id=
"https"
value=
"HTTPS"
/><label
for=
"https"
>
Https Mode
</label></li>
</ul>
</div>
<div
class=
"clear"
></div><br/>
<div
id=
"file_navigation"
>
<h2
>
Your project folder
</h2
>
<h2
class=
'title'
>
Your project folder
</h2><br/
>
<div
id=
"fileTree"
class=
"file_tree"
></div>
</div>
{% endblock %}
slapos/runner/templates/manageProject.html
View file @
7a9ce4ff
{% extends "layout.html" %}
{% block title %}Manage your Project{% endblock %}
{% block head %}
{{ super() }}
{{ super() }}
<script
src=
"{{ url_for('static', filename='js/jquery/jqueryFileTree.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='js/scripts/repo.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
{% endblock %}
...
...
@@ -33,12 +33,17 @@
<label
for=
'branchname'
>
Branch Name:
</label>
<input
type=
"text"
name=
"branchname"
id=
"branchname"
size=
'22'
value=
"Enter the branch name..."
/>
<input
type=
"submit"
name=
"addbranch"
id =
"addbranch"
value=
"Add"
class=
"button"
/>
<div
style=
"margin-left:166px;"
>
<label
for=
'checkout'
>
Checkout existing branch:
</label>
<input
type=
"text"
name=
"checkout"
id=
"checkout"
size=
'22'
value=
"Existing branch name..."
/>
<input
type=
"submit"
name=
"docheckout"
id =
"docheckout"
value=
"Checkout"
class=
"button"
/>
</div>
<br/>
<!--<label for='pullbranch'>Update your local repository: </label>-->
<!--<input type="submit" name="pullbranch" id ="pullbranch" value="Pull" class="button"/>-->
<!--<img class="waitting" id="pullimgwaitting" src="{{ url_for('static', filename='images/waiting.gif') }}" alt="" />-->
</div>
</div>
</div>
<div
id=
"push"
style=
"margin-bottom:20px;"
>
<h2>
Commit All your changes (On active branch)
</h2>
<div
style=
"margin-left:15px;"
>
...
...
@@ -46,7 +51,7 @@
<input
type=
"text"
name=
"commitmsg"
id=
"commitmsg"
size=
'40'
value=
"Enter message..."
/>
<input
type=
"submit"
name=
"commit"
id =
"commit"
value=
"Commit"
class=
"button"
/>
<img
class=
"waitting"
id=
"imgwaitting"
src=
"{{ url_for('static', filename='images/waiting.gif') }}"
alt=
""
/>
</div>
</div>
</div>
<br/>
</div>
...
...
slapos/runner/templates/projectDiff.html
View file @
7a9ce4ff
...
...
@@ -21,7 +21,7 @@
{% block body %}
<form
action=
"{{ url_for('manageProject') }}"
method=
get
>
<dl>
<dd><h2>
Diff file for "{{project}}"
</h2></dd>
<dd><h2
class=
'title'
>
Diff file for "{{project}}"
</h2></dd>
<dd>
<div
class=
"main_content"
>
<pre
id=
"editor"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment