Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Managetests
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Managetests
Commits
c49b31b3
Commit
c49b31b3
authored
Nov 29, 2016
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show the commit hash (with a link) of a branch
parent
3af66a35
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
managetests/branches.py
managetests/branches.py
+31
-2
managetests/frontend/templates/index.html
managetests/frontend/templates/index.html
+20
-1
No files found.
managetests/branches.py
View file @
c49b31b3
...
...
@@ -21,7 +21,7 @@ import shutil
import
json
BRANCH_DIR_VERSION
=
"
2
"
BRANCH_DIR_VERSION
=
"
3
"
class
Branch
:
...
...
@@ -82,7 +82,7 @@ class Branch:
return
False
# All the files must be be present
files
=
[
"version"
,
"config.json"
]
files
=
[
"version"
,
"co
mmit"
,
"co
nfig.json"
]
for
file
in
files
:
file
=
root
/
file
if
not
(
file
.
exists
()
and
file
.
is_file
()):
...
...
@@ -130,6 +130,28 @@ class Branch:
with
file
.
open
()
as
f
:
self
.
config
=
json
.
load
(
f
)
def
commit
(
self
):
"""Load the commit of this branch"""
file
=
self
.
manager
.
root
/
"branches"
/
self
.
name
/
"commit"
if
file
.
exists
():
with
file
.
open
()
as
f
:
return
f
.
read
().
strip
()
else
:
return
""
def
commit_url
(
self
):
"""Get the URL of a commit"""
commit
=
self
.
commit
()
if
not
commit
:
return
None
return
"%s/%s/commit/%s"
%
(
self
.
manager
.
config
[
"gitlab-url"
],
self
.
manager
.
config
[
"gitlab-project"
],
commit
,
)
def
exec_command
(
self
,
raw_command
,
replaces
=
None
,
build
=
False
):
"""Exec a command in the context of the branch"""
args
,
kwargs
=
self
.
command_popen_args
(
raw_command
,
replaces
,
build
)
...
...
@@ -212,6 +234,13 @@ class Branch:
"checkout"
,
"-f"
,
self
.
name
,
],
stdout
=
log_file
.
open
(
"a"
),
stderr
=
subprocess
.
STDOUT
)
# Get the commit of the branch
commit_file
=
branch
/
"commit"
subprocess
.
call
(
[
"git"
,
"--git-dir"
,
git_dir
,
"rev-parse"
,
self
.
name
],
stdout
=
commit_file
.
open
(
"w"
),
stderr
=
log_file
.
open
(
"a"
),
)
# Copy and load the configuration file
if
not
(
build_dir
/
"managetests.json"
).
exists
():
log
(
"[!] No managetests.json found in the branch!"
)
...
...
managetests/frontend/templates/index.html
View file @
c49b31b3
...
...
@@ -61,7 +61,14 @@
<a
href=
"{{ branch.mr_url }}"
>
!{{ branch.mr_id }}
</a>
</td>
{% endif %}
<td>
-
</td>
<td>
{% set commit = branch.commit() %}
{% if not commit %}-{% else %}
<a
href=
"{{ branch.commit_url() }}"
>
{{ commit[:7] }}
</a>
{% endif %}
</td>
<td>
{% if branch.has_build_log() %}
<a
href=
"{{ url_for("
build_log
",
branch=
branch.name)
}}"
>
Build log
</a>
{% endif %}
...
...
@@ -101,6 +108,18 @@
</ul>
{% endif %}
{% set commit = branch.commit() %}
{% if commit %}
<ul
class=
"inline"
>
<li>
Commit corrente:
<a
href=
"{{ branch.commit_url() }}"
>
{{ commit[:7] }}
</a>
</li>
</ul>
{% endif %}
<ul
class=
"inline"
>
{% if branch.has_build_log() %}
<li><a
href=
"{{ url_for("
build_log
",
branch=
branch.name)
}}"
>
Build log
</a></a>
...
...
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