Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.8.1

- Commit graph: dimming the commits outside the history of your HEAD is now off by default and remembered, with the
new setting `gitLore.graph.highlightCurrentBranch`. The target button in the toolbar still toggles it, and changes
the setting.
- Commit graph: the target button, when on, looks like VS Code's own toggles (the ones in the search box) instead of
a gray square.

## 0.8.0

- Contributors chart: the chart icon in the Contributors view (or `Show Contributors Chart`) opens a bubble per
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ No account, no sign-in, no trial, no paywall, no telemetry. MIT licensed.
ones tinted, tags neutral). Hover a message, author or badge for the full text. A row above HEAD shows your
uncommitted changes. Choose all branches, local branches or the current branch, filter by message, author, ref or
SHA, and scroll to load more. Drag the graph's edge to make it wider (double-click to reset).
With many branches, commits outside the history of your HEAD are dimmed (toggle it from the toolbar) and a floating
With many branches, the target button in the toolbar dims the commits outside the history of your HEAD and a floating
button takes you back to your commit when it is out of view.
- *Commit details:* click a commit (or press Enter; arrows move between rows) to open its message, author, parents and
changed files inline. Each file opens its diff; right-click it to open it at that revision, compare it with the
Expand All @@ -60,6 +60,7 @@ Everything is localized in English and Spanish.
| Setting | Default | |
|---|---|---|
| `gitLore.currentLine.enabled` | `true` | Show the blame of the current line. Also `Git Lore: Toggle Current Line Blame`. |
| `gitLore.graph.highlightCurrentBranch` | `false` | In the commit graph, dim the commits that are not in the history of your HEAD. Also the target button in the graph toolbar. |

The colors are themeable: `gitLore.currentLineForeground`, `gitLore.fileBlameForeground`, `gitLore.fileBlameBackground`.

Expand Down
7 changes: 6 additions & 1 deletion media/grafo.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ body {
#fetch:active svg { transform: translateY(2px); }
#fetch svg { transition: transform .2s var(--muelle); }
.boton:disabled { opacity: .5; cursor: default; }
#resaltar[aria-pressed="true"] { color: var(--vscode-focusBorder); background: var(--vscode-toolbar-activeBackground, var(--vscode-toolbar-hoverBackground)); }
/* como los conmutadores del buscador de VS Code (Aa, .*): fondo y borde del tema, el icono se sigue leyendo */
#resaltar[aria-pressed="true"] {
color: var(--vscode-inputOption-activeForeground, var(--vscode-icon-foreground));
background: var(--vscode-inputOption-activeBackground, rgba(36, 137, 219, .51));
box-shadow: inset 0 0 0 1px var(--vscode-inputOption-activeBorder, #2488db);
}

/* lo que no es historia de HEAD queda en segundo plano; las líneas no, que son las que llevan a tu rama */
.fila > .texto, .fila > .autor, .fila > .fecha, .fila > .sha, .nodo { transition: opacity .2s ease-out; }
Expand Down
9 changes: 7 additions & 2 deletions media/grafo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
const aqui = document.getElementById('aqui');
/** @type {{sha: string, nombre: string} | null} */
let actual = null;
let resaltar = (vscode.getState() || {}).resaltar !== false;
let resaltar = window.RESALTAR === true;
let buscandoHead = 0; // páginas que quedan por pedir buscando la fila de HEAD
let headInalcanzable = false; // se buscó y no está en este alcance: no se ofrece hasta la próxima recarga
let filas = [];
Expand Down Expand Up @@ -297,6 +297,11 @@
}

window.addEventListener('message', ({ data: m }) => {
if (m.tipo === 'resaltar') {

Check warning on line 300 in media/grafo.js

View check run for this annotation

Rufus Centinela / centinela / PR

semgrep

insufficient-postmessage-origin-validation: No validation of origin is done by the addEventListener API. It may be possible to exploit this flaw to perform Cross Origin attacks such as Cross-Site Scripting(XSS).
resaltar = m.valor === true;
aplicarResaltado();
return;
}
if (m.tipo === 'error') {
pidiendo = false;
cargando(false);
Expand Down Expand Up @@ -383,8 +388,8 @@
}
botonResaltar.addEventListener('click', () => {
resaltar = !resaltar;
vscode.setState({ ...(vscode.getState() || {}), resaltar });
aplicarResaltado();
vscode.postMessage({ tipo: 'resaltar', valor: resaltar });
});
aplicarResaltado();

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "git-lore",
"displayName": "%displayName%",
"description": "%description%",
"version": "0.8.0",
"version": "0.8.1",
"publisher": "jlopez",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -729,6 +729,11 @@
"type": "boolean",
"default": true,
"description": "%config.currentLine%"
},
"gitLore.graph.highlightCurrentBranch": {
"type": "boolean",
"default": false,
"description": "%config.graphHighlight%"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion package.nls.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
"command.previousRevision": "Abrir la revisión anterior",
"command.nextRevision": "Abrir la revisión siguiente",
"view.contributors": "Colaboradores",
"command.contributorsChart": "Ver gráfico de colaboradores"
"command.contributorsChart": "Ver gráfico de colaboradores",
"config.graphHighlight": "Grafo de commits: atenúa los commits que no están en la historia de la rama actual. El botón de la diana en la barra del grafo lo activa y desactiva."
}
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
"command.previousRevision": "Open Previous Revision",
"command.nextRevision": "Open Next Revision",
"view.contributors": "Contributors",
"command.contributorsChart": "Show Contributors Chart"
"command.contributorsChart": "Show Contributors Chart",
"config.graphHighlight": "Commit Graph: dim the commits that are not in the history of the current branch. The target button in the graph toolbar toggles it."
}
23 changes: 19 additions & 4 deletions src/grafo-vista.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ const t = vscode.l10n.t;
const PAGINA = 300;
const MAX_RECARGA = 3 * PAGINA; // tras una acción no se vuelve a pedir todo lo que se haya cargado con scroll
const SHA = /^[0-9a-f]{40,64}$/;
const RESALTAR = 'graph.highlightCurrentBranch';
const resaltarAhora = () => vscode.workspace.getConfiguration('gitLore').get(RESALTAR, false) === true;
// no es hexadecimal: nunca pasa por SHA ni llega a git
const PENDIENTES = 'pendientes';
const paneles = new Map(); // raíz → panel
const vistas = new Map(); // id opaco del panel → { repo, recargar }: el menú contextual dice de qué panel viene

function html(webview, raizExt, nonce, id) {
function html(webview, raizExt, nonce, id, resaltar) {
const recurso = f => webview.asWebviewUri(vscode.Uri.joinPath(raizExt, 'media', f));
const textos = {
copiado: t('Copied'), sinCommits: t('No commits'), copiar: t('Copy SHA'), ficheros: t('Files'), padres: t('Parents'),
Expand All @@ -43,7 +45,7 @@ function html(webview, raizExt, nonce, id) {
<option value="actual">${t('Current branch')}</option>
</select>
<span id="cuenta" class="cuenta" aria-live="polite"></span>
<button id="resaltar" class="boton" aria-pressed="true" title="${t('Highlight the history of the current branch')}" aria-label="${t('Highlight the history of the current branch')}"><svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="5.5" fill="none" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="8" r="2" fill="currentColor"/></svg></button>
<button id="resaltar" class="boton" aria-pressed="${resaltar}" title="${t('Highlight the history of the current branch')}" aria-label="${t('Highlight the history of the current branch')}"><svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="5.5" fill="none" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="8" r="2" fill="currentColor"/></svg></button>
<button id="fetch" class="boton" title="${t('Fetch from all remotes')}" aria-label="${t('Fetch from all remotes')}"><svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1v9m-4-4 4 4 4-4M2 14h12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
<button id="refrescar" class="boton" title="${t('Refresh')}" aria-label="${t('Refresh')}"><svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><path d="M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
</header>
Expand All @@ -52,7 +54,7 @@ function html(webview, raizExt, nonce, id) {
<button id="aqui" class="aqui" hidden></button>
<div id="tirador" class="tirador" role="separator" aria-orientation="vertical" tabindex="0" aria-valuemin="24"
aria-label="${t('Graph width')}" title="${t('Drag to resize the graph, double-click to reset')}"></div>
<script nonce="${nonce}">window.TEXTOS = ${JSON.stringify(textos)}; window.PANEL = ${JSON.stringify(id)};</script>
<script nonce="${nonce}">window.TEXTOS = ${JSON.stringify(textos)}; window.PANEL = ${JSON.stringify(id)}; window.RESALTAR = ${resaltar};</script>
<script nonce="${nonce}" src="${recurso('grafo.js')}"></script>
</body>
</html>`;
Expand Down Expand Up @@ -220,6 +222,16 @@ function abrir(context, repo) {
alcance = m.valor;
return cargar(true);
}
// el botón del grafo cambia el ajuste: así lo recuerdan los demás paneles y las próximas sesiones
if (m.tipo === 'resaltar' && typeof m.valor === 'boolean') {
const cfg = vscode.workspace.getConfiguration('gitLore');
const enWorkspace = cfg.inspect(RESALTAR).workspaceValue !== undefined;
return cfg.update(RESALTAR, m.valor, enWorkspace ? vscode.ConfigurationTarget.Workspace : vscode.ConfigurationTarget.Global)
.then(undefined, e => {
vscode.window.showErrorMessage(e.message);
enviar({ tipo: 'resaltar', valor: resaltarAhora() }); // el botón cambió antes de guardar: vuelve al real
});
}
if (m.tipo === 'verCambios') { return vscode.commands.executeCommand('workbench.view.scm'); }
if (m.tipo === 'fetch') {
return repo.fetch({ all: true })
Expand All @@ -236,6 +248,9 @@ function abrir(context, repo) {
if (m.tipo === 'remoto') { return abrirEnRemoto(repo, m.sha).then(undefined, fallo); }
if (m.tipo === 'copiar') { return copiarSha(m.sha); }
}),
vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(`gitLore.${RESALTAR}`)) { enviar({ tipo: 'resaltar', valor: resaltarAhora() }); }
}),
];

// crear una rama o un tag desde la terminal no dispara onDidChange: se vigilan los ficheros de refs
Expand All @@ -258,7 +273,7 @@ function abrir(context, repo) {
clearTimeout(esperaRefs);
});

panel.webview.html = html(panel.webview, context.extensionUri, crypto.randomBytes(16).toString('base64'), id);
panel.webview.html = html(panel.webview, context.extensionUri, crypto.randomBytes(16).toString('base64'), id, resaltarAhora());
}

function registrar(context, protegido) {
Expand Down