refs #2371 hide commits that can't be restored
parent
73c0220ab3
commit
d048ee782c
|
|
@ -2559,6 +2559,7 @@ def git_get_commits(repo, branch):
|
||||||
|
|
||||||
max_commits = request.args.get('max_commits') or 100
|
max_commits = request.args.get('max_commits') or 100
|
||||||
skip_commits = request.args.get('skip') or 0
|
skip_commits = request.args.get('skip') or 0
|
||||||
|
filter_commits = (request.args.get('filter_commits') or 1) == 1
|
||||||
|
|
||||||
|
|
||||||
git_repo = git.Repo(repo_path)
|
git_repo = git.Repo(repo_path)
|
||||||
|
|
@ -2580,14 +2581,41 @@ def git_get_commits(repo, branch):
|
||||||
hash_to_tag[sha] = hash_to_tag[sha] + [ tag.name ]
|
hash_to_tag[sha] = hash_to_tag[sha] + [ tag.name ]
|
||||||
|
|
||||||
|
|
||||||
|
first_commit = next(git_repo.iter_commits(reverse=True))
|
||||||
|
|
||||||
commits = []
|
commits = []
|
||||||
|
git_repo.iter_commits()
|
||||||
for com in git_repo.iter_commits(branch, max_count = max_commits, skip = skip_commits):
|
for com in git_repo.iter_commits(branch, max_count = max_commits, skip = skip_commits):
|
||||||
tag_list = []
|
tag_list = []
|
||||||
|
|
||||||
|
# Initial check-ins contain only a .gitignore, used to test the repository is working,
|
||||||
|
# and do a force push to the destination.
|
||||||
|
#
|
||||||
|
# We don't want to show this one to the users by default, since it's not a functional
|
||||||
|
# restoration point.
|
||||||
|
#
|
||||||
|
# To make sure users can use git normally, we try to detect it in a slightly paranoid
|
||||||
|
# manner here. We want to avoid magic markers or to always skip the first commit, in
|
||||||
|
# case it might actually contain data.
|
||||||
|
skip_this_commit = False
|
||||||
|
|
||||||
|
# Check:
|
||||||
|
# * First commit, and we want filtering
|
||||||
|
# * There's only one blob
|
||||||
|
# * The one file is .gitignore.
|
||||||
|
if com == first_commit and filter_commits:
|
||||||
|
if len(com.tree.blobs) == 1:
|
||||||
|
for file in com.tree.traverse(depth=1, visit_once=False):
|
||||||
|
if file.name == ".gitignore" and file.type == "blob":
|
||||||
|
skip_this_commit = True
|
||||||
|
|
||||||
|
if skip_this_commit:
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
if com.hexsha in hash_to_tag:
|
if com.hexsha in hash_to_tag:
|
||||||
tag_list = hash_to_tag[com.hexsha]
|
tag_list = hash_to_tag[com.hexsha]
|
||||||
|
|
||||||
|
|
||||||
commits = commits + [
|
commits = commits + [
|
||||||
{
|
{
|
||||||
"hexsha" : com.hexsha,
|
"hexsha" : com.hexsha,
|
||||||
|
|
|
||||||
|
|
@ -1982,9 +1982,6 @@ paths:
|
||||||
|
|
||||||
Especificando **ssh_key** se agrega la cclave especificada directamente.
|
Especificando **ssh_key** se agrega la cclave especificada directamente.
|
||||||
|
|
||||||
Especificando **oglive** se descarga si es necesario el .iso, se monta, y se extrae la clave.
|
|
||||||
Esta acción se hace en el fondo, y se devuelve un job_id.
|
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- "Git"
|
- "Git"
|
||||||
parameters:
|
parameters:
|
||||||
|
|
@ -2006,10 +2003,6 @@ paths:
|
||||||
type: string
|
type: string
|
||||||
example: "OgLive r20250518"
|
example: "OgLive r20250518"
|
||||||
required: False
|
required: False
|
||||||
oglive:
|
|
||||||
type: string
|
|
||||||
example: "https://ognproject.evlt.uma.es/oglive/ogLive-noble-6.8.0-31-generic-amd64-r20250518.cf13a6d_20250519.iso"
|
|
||||||
required: False
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: "Exito"
|
description: "Exito"
|
||||||
|
|
@ -2270,7 +2263,12 @@ paths:
|
||||||
get:
|
get:
|
||||||
summary: "Obtener lista de commits en una rama"
|
summary: "Obtener lista de commits en una rama"
|
||||||
description: |
|
description: |
|
||||||
Devuelve una lista de commits de Git
|
Devuelve una lista de commits de Git.
|
||||||
|
|
||||||
|
**Filtrado de commits:**
|
||||||
|
Por defecto algunos commits que no son utiles para restaurar una imagen se ocultan.
|
||||||
|
Pasar filter_commits=0 para desactivar esta funcionalidad y ver todos los commits
|
||||||
|
del repositorio.
|
||||||
tags:
|
tags:
|
||||||
- "Git"
|
- "Git"
|
||||||
parameters:
|
parameters:
|
||||||
|
|
@ -2294,6 +2292,11 @@ paths:
|
||||||
required: false
|
required: false
|
||||||
type: int
|
type: int
|
||||||
description: "Commits a saltar (para paginación)"
|
description: "Commits a saltar (para paginación)"
|
||||||
|
- name: filter_commits
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
type: int
|
||||||
|
description: "Si aplicar filtrado de commits. Por defecto 1."
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: "Lista de commits"
|
description: "Lista de commits"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue