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
Guillaume Hervier
slapos.toolbox
Commits
7a935c83
Commit
7a935c83
authored
Jan 25, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Git commit+push and Git diff to webrunner
parent
98d40ee5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
11 deletions
+63
-11
slapos/runner/gittools.py
slapos/runner/gittools.py
+63
-11
No files found.
slapos/runner/gittools.py
View file @
7a935c83
...
...
@@ -63,17 +63,69 @@ def switchBranch(project, name):
if
name
==
current_branch
:
json
=
"This is already your active branch for this project"
else
:
branch
=
none
i
=
0
json
=
"Error: Can not found branch '"
+
name
+
"'"
repo
.
heads
.
master
.
checkout
()
for
b
in
branches
:
if
b
.
name
==
name
:
branch
=
b
if
branch
!=
none
:
repo
.
heads
.
master
.
checkout
()
repo
.
heads
.
branch
.
checkout
()
repo
.
heads
[
i
].
checkout
()
code
=
1
else
:
json
=
""
break
i
=
i
+
1
except
Exception
,
e
:
json
=
str
(
e
)
return
jsonify
(
code
=
code
,
result
=
json
)
def
createBranch
(
project
,
name
):
code
=
0
json
=
"Error: Can not found branch '"
+
name
+
"'"
json
=
""
try
:
repo
=
Repo
(
project
)
b
=
repo
.
create_head
(
name
)
code
=
1
except
Exception
,
e
:
json
=
str
(
e
)
return
jsonify
(
code
=
code
,
result
=
json
)
def
getDiff
(
project
):
result
=
""
try
:
repo
=
Repo
(
project
)
git
=
repo
.
git
current_branch
=
repo
.
active_branch
.
name
result
=
git
.
diff
(
current_branch
)
except
Exception
,
e
:
result
=
str
(
e
)
return
result
def
gitPush
(
project
,
msg
,
fetch
=
False
):
code
=
0
json
=
""
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
)
commit
=
True
if
fetch
:
git
.
fetch
(
'--all'
)
git
.
rebase
(
'origin/'
+
current_branch
)
#push changes to repo
git
.
push
(
'origin'
,
current_branch
)
code
=
1
else
:
json
=
"Nothing to be commited"
code
=
1
except
Exception
,
e
:
if
commit
:
git
.
reset
(
"HEAD^1"
)
#undo previous commit
json
=
str
(
e
)
return
jsonify
(
code
=
code
,
result
=
json
)
\ No newline at end of file
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