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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.toolbox
Commits
23c574f4
Commit
23c574f4
authored
Sep 09, 2013
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slaprunner : separation of commit and push
parent
d2f691ec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
30 deletions
+79
-30
slapos/runner/gittools.py
slapos/runner/gittools.py
+27
-22
slapos/runner/static/js/scripts/repo.js
slapos/runner/static/js/scripts/repo.js
+32
-4
slapos/runner/templates/layout.html
slapos/runner/templates/layout.html
+1
-1
slapos/runner/templates/manageProject.html
slapos/runner/templates/manageProject.html
+7
-1
slapos/runner/views.py
slapos/runner/views.py
+12
-2
No files found.
slapos/runner/gittools.py
View file @
23c574f4
...
...
@@ -117,35 +117,40 @@ def getDiff(project):
result
=
safeResult
(
str
(
e
))
return
result
def
gitPush
(
project
,
msg
):
"""Commit and Push changes for the specified repository
def
gitCommit
(
project
,
msg
):
"""Commit changes for the specified repository
Args:
project: directory of the local repository
msg: commit message"""
code
=
0
json
=
""
repo
=
Repo
(
project
)
if
repo
.
is_dirty
:
git
=
repo
.
git
#add file to be commited
files
=
repo
.
untracked_files
for
f
in
files
:
git
.
add
(
f
)
#Commit all modified and untracked files
git
.
commit
(
'-a'
,
'-m'
,
msg
)
else
:
code
=
1
json
=
"Nothing to be commited"
return
jsonify
(
code
=
code
,
result
=
json
)
def
gitPush
(
project
):
"""Push changes for the specified repository
Args:
project: directory of the local repository
msg: commit message"""
code
=
0
json
=
""
undo_commit
=
False
try
:
repo
=
Repo
(
project
)
if
repo
.
is_dirty
:
git
=
repo
.
git
current_branch
=
repo
.
active_branch
.
name
#add file to be commited
files
=
repo
.
untracked_files
for
f
in
files
:
git
.
add
(
f
)
#Commit all modified and untracked files
git
.
commit
(
'-a'
,
'-m'
,
msg
)
undo_commit
=
True
#push changes to repo
git
.
push
(
'origin'
,
current_branch
)
code
=
1
else
:
json
=
"Nothing to be commited"
code
=
1
#push changes to repo
current_branch
=
repo
.
active_branch
.
name
git
.
push
(
'origin'
,
current_branch
)
code
=
1
except
Exception
as
e
:
if
undo_commit
:
git
.
reset
(
"HEAD~"
)
#undo previous commit
json
=
safeResult
(
str
(
e
))
return
jsonify
(
code
=
code
,
result
=
json
)
...
...
slapos/runner/static/js/scripts/repo.js
View file @
23c574f4
...
...
@@ -23,6 +23,7 @@ $(document).ready(function () {
urldata
=
$
(
"
input#workdir
"
).
val
()
+
"
/
"
+
project
;
$
(
"
#status
"
).
empty
();
$
(
"
#commit
"
).
hide
();
$
(
"
#push
"
).
hide
();
$
(
"
#flash
"
).
empty
();
if
(
project
===
""
)
{
...
...
@@ -45,7 +46,8 @@ $(document).ready(function () {
//alert(message);
$
(
"
#status
"
).
append
(
"
<p>
"
+
message
+
"
</p>
"
);
if
(
data
.
dirty
)
{
$
(
"
#push
"
).
show
();
$
(
"
#commit
"
).
show
();
$
(
"
#push
"
).
show
();
$
(
"
#status
"
).
append
(
"
<br/><h2>Display Diff for current Project</h2>
"
);
$
(
"
#status
"
).
append
(
"
<p style='font-size:15px;'>You have changes in your project.
"
+
"
<a href='
"
+
$SCRIPT_ROOT
+
"
/getProjectDiff/
"
...
...
@@ -131,11 +133,11 @@ $(document).ready(function () {
send
=
true
;
var
project
=
$
(
"
#project
"
).
val
();
$
(
"
#imgwaitting
"
).
fadeIn
(
'
normal
'
);
$
(
"
#commit
"
).
empty
();
//
$("#commit").empty();
$
(
"
#commit
"
).
attr
(
"
value
"
,
"
Wait...
"
);
$
.
ajax
({
type
:
"
POST
"
,
url
:
$SCRIPT_ROOT
+
'
/
push
ProjectFiles
'
,
url
:
$SCRIPT_ROOT
+
'
/
commit
ProjectFiles
'
,
data
:
{
project
:
$
(
"
input#workdir
"
).
val
()
+
"
/
"
+
project
,
msg
:
$
(
"
input#commitmsg
"
).
val
()},
success
:
function
(
data
)
{
if
(
data
.
code
===
1
)
{
...
...
@@ -156,7 +158,33 @@ $(document).ready(function () {
});
return
false
;
});
$
(
"
#push
"
).
click
(
function
()
{
if
(
send
)
{
return
false
;
}
send
=
true
;
var
project
=
$
(
"
#project
"
).
val
();
$
.
ajax
({
type
:
"
POST
"
,
url
:
$SCRIPT_ROOT
+
'
/pushProjectFiles
'
,
data
:
{
project
:
$
(
"
input#workdir
"
).
val
()
+
"
/
"
+
project
};
success
:
function
(
data
)
{
if
(
data
.
code
===
1
)
{
if
(
data
.
result
!==
""
)
{
$
(
"
#error
"
).
Popup
(
data
.
result
,
{
type
:
'
error
'
,
duration
:
5000
});
}
else
{
$
(
"
#error
"
).
Popup
(
"
The local commits have correctly been saved on the server
"
,
{
type
:
'
confirm
'
,
duration
:
3000
});
}
gitStatus
();
}
else
{
$
(
"
#error
"
).
Popup
(
data
.
result
,
{
type
:
'
error
'
});
}
$
(
"
#push
"
).
hide
();
send
=
false
;
}
});
return
false
;
)};
/*
$("#pullbranch").click(function (){
if (send){
...
...
slapos/runner/templates/layout.html
View file @
23c574f4
...
...
@@ -66,7 +66,7 @@
</div>
<div
class=
"wmenu"
>
<ul>
<li><a
href=
"{{ url_for('editSoftwareProfile') }}"
>
Profiles
3
</a></li>
<li><a
href=
"{{ url_for('editSoftwareProfile') }}"
>
Profiles
4
</a></li>
<li><a
href=
"{{ url_for('browseWorkspace') }}"
>
Workspace
</a></li>
<li
class=
'sep'
></li>
<li><a
href=
"{{ url_for('runSoftwareProfile') }}"
id=
"softrun"
>
Run software
</a></li>
...
...
slapos/runner/templates/manageProject.html
View file @
23c574f4
...
...
@@ -40,7 +40,7 @@
<!--<img class="waitting" id="pullimgwaitting" src="{{ url_for('static', filename='images/waiting.gif') }}" alt="" />-->
</div>
</div>
<div
id=
"
push
"
style=
"margin-bottom:20px;"
>
<div
id=
"
commit
"
style=
"margin-bottom:20px;"
>
<h2>
Commit All your changes (On active branch)
</h2>
<div
style=
"margin-left:15px;"
>
<label
for=
'commitmsg'
>
Commit message:
</label>
...
...
@@ -49,6 +49,12 @@
<img
class=
"waitting"
id=
"imgwaitting"
src=
"{{ url_for('static', filename='images/waiting.gif') }}"
alt=
""
/>
</div>
</div>
<div
id=
"push"
style=
"margin-bottom:20px;"
>
<h2>
Push your Last Commits
</h2>
<div
style=
"margin-left:15px;"
>
<input
type=
"submit"
name=
"push"
id=
"push"
value=
"Push"
class=
"button"
/>
</div>
</div>
<br/>
</div>
</div>
...
...
slapos/runner/views.py
View file @
23c574f4
...
...
@@ -28,7 +28,7 @@ from slapos.runner.utils import (checkSoftwareFolder, configNewSR, getFolder,
from
slapos.runner.fileBrowser
import
FileBrowser
from
slapos.runner.gittools
import
(
cloneRepo
,
gitStatus
,
switchBranch
,
addBranch
,
getDiff
,
gitPush
,
gitPull
)
addBranch
,
getDiff
,
git
Commit
,
git
Push
,
gitPull
)
app
=
Flask
(
__name__
)
...
...
@@ -389,12 +389,20 @@ def getProjectDiff(project):
path
=
os
.
path
.
join
(
app
.
config
[
'workspace'
],
project
)
return
render_template
(
'projectDiff.html'
,
project
=
project
,
diff
=
getDiff
(
path
))
@
login_required
()
def
commitProjectFiles
():
#import pdb; pdb.set_trace()
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
if
path
:
return
gitCommit
(
path
,
request
.
form
[
'msg'
])
else
:
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
@
login_required
()
def
pushProjectFiles
():
path
=
realpath
(
app
.
config
,
request
.
form
[
'project'
])
if
path
:
return
gitPush
(
path
,
request
.
form
[
'msg'
]
)
return
gitPush
(
path
)
else
:
return
jsonify
(
code
=
0
,
result
=
"Can not read folder: Permission Denied"
)
...
...
@@ -673,6 +681,8 @@ app.add_url_rule("/checkFileType", 'checkFileType', checkFileType,
methods
=
[
'POST'
])
app
.
add_url_rule
(
"/pullProjectFiles"
,
'pullProjectFiles'
,
pullProjectFiles
,
methods
=
[
'POST'
])
app
.
add_url_rule
(
"/commitProjectFiles"
,
'commitProjectFiles'
,
commitProjectFiles
,
methods
=
[
'POST'
])
app
.
add_url_rule
(
"/pushProjectFiles"
,
'pushProjectFiles'
,
pushProjectFiles
,
methods
=
[
'POST'
])
app
.
add_url_rule
(
"/getProjectDiff/<project>"
,
'getProjectDiff'
,
getProjectDiff
,
...
...
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