Преглед на файлове

Adds defaultDateShortFormat setting

Changes fetch date to  respect date settings
main
Eric Amodio преди 6 години
родител
ревизия
24b0247175
променени са 6 файла, в които са добавени 48 реда и са изтрити 12 реда
  1. +8
    -0
      CHANGELOG.md
  2. +1
    -0
      README.md
  3. +6
    -0
      package.json
  4. +1
    -1
      src/ui/config.ts
  5. +17
    -0
      src/ui/settings/index.html
  6. +15
    -11
      src/views/nodes/repositoryNode.ts

+ 8
- 0
CHANGELOG.md Целия файл

@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds `gitlens.defaultDateShortFormat` setting to specify how short absolute dates will be formatted by default
### Changed
- Changes the fetch date in the _Repositories_ view to respect the date style setting (`gitlens.defaultDateStyle`) and uses the new `gitlens.defaultDateShortFormat` setting for formatting
### Fixed
- Fixes [#605](https://github.com/eamodio/vscode-gitlens/issues/605) — Show More Commits not working

+ 1
- 0
README.md Целия файл

@ -655,6 +655,7 @@ GitLens is highly customizable and provides many configuration settings to allow
| Name | Description |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.defaultDateFormat` | Specifies how absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.defaultDateShortFormat` | Specifies how short absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.defaultDateStyle` | Specifies how dates will be displayed by default |
| `gitlens.defaultGravatarsStyle` | Specifies the style of the gravatar default (fallback) images<br /><br />`identicon` - a geometric pattern<br />`mm` - a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)<br />`monsterid` - a monster with different colors, faces, etc<br />`retro` - 8-bit arcade-style pixelated faces<br />`robohash` - a robot with different colors, faces, etc<br />`wavatar` - a face with differing features and backgrounds |
| `gitlens.insiders` | Specifies whether to enable experimental features |

+ 6
- 0
package.json Целия файл

@ -419,6 +419,12 @@
"markdownDescription": "Specifies how absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats",
"scope": "window"
},
"gitlens.defaultDateShortFormat": {
"type": "string",
"default": null,
"markdownDescription": "Specifies how short absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats",
"scope": "window"
},
"gitlens.defaultDateStyle": {
"type": "string",
"default": "relative",

+ 1
- 1
src/ui/config.ts Целия файл

@ -27,6 +27,7 @@ export interface Config {
codeLens: CodeLensConfig;
debug: boolean;
defaultDateFormat: string | null;
defaultDateShortFormat: string | null;
defaultDateStyle: DateStyle;
defaultGravatarsStyle: GravatarDefaultStyle;
heatmap: {
@ -367,7 +368,6 @@ export interface ViewsConfig {
commitDescriptionFormat: string;
commitFormat: string;
compare: CompareViewConfig;
// dateFormat: string | null;
defaultItemLimit: number;
lineHistory: LineHistoryViewConfig;
repositories: RepositoriesViewConfig;

+ 17
- 0
src/ui/settings/index.html Целия файл

@ -107,6 +107,23 @@
<i class="icon icon__info"></i>
</a>
</div>
<div class="settings-group__setting nowrap">
<label for="defaultDateShortFormat">Absolute&nbsp;short&nbsp;date&nbsp;format</label>
<input
class="setting"
id="defaultDateShortFormat"
name="defaultDateShortFormat"
type="text"
placeholder="MMM D, YYYY"
/>
<a
class="link__learn-more"
title="See Moment.js docs for valid date formats"
href="https://momentjs.com/docs/#/displaying/format/"
>
<i class="icon icon__info"></i>
</a>
</div>
</div>
<h3 class="settings-group__header">Keyboard Shortcuts</h3>

+ 15
- 11
src/views/nodes/repositoryNode.ts Целия файл

@ -12,6 +12,7 @@ import {
RepositoryFileSystemChangeEvent
} from '../../git/gitService';
import { Dates, debug, Functions, gate, log, Strings } from '../../system';
import { DateStyle } from '../../ui/config';
import { RepositoriesView } from '../repositoriesView';
import { BranchesNode } from './branchesNode';
import { BranchNode } from './branchNode';
@ -97,7 +98,7 @@ export class RepositoryNode extends SubscribeableViewNode {
const lastFetchedTooltip = this.formatLastFetched({
prefix: `${Strings.pad(GlyphChars.Dash, 2, 2)}Last fetched on `,
format: 'dddd MMMM Do, YYYY h:mm a'
format: Container.config.defaultDateFormat || 'dddd MMMM Do, YYYY h:mm a'
});
let description;
@ -200,14 +201,14 @@ export class RepositoryNode extends SubscribeableViewNode {
protected async subscribe() {
const disposables = [this.repo.onDidChange(this.onRepoChanged, this)];
if (Container.config.defaultDateStyle === DateStyle.Relative) {
disposables.push(Functions.interval(() => void this.updateLastFetched(), 60000));
}
if (this.includeWorkingTree) {
disposables.push(
this.repo.onDidChangeFileSystem(this.onFileSystemChanged, this),
{
dispose: () => this.repo.stopWatchingFileSystem()
},
Functions.interval(() => void this.updateLastFetched(), 60000)
);
disposables.push(this.repo.onDidChangeFileSystem(this.onFileSystemChanged, this), {
dispose: () => this.repo.stopWatchingFileSystem()
});
this.repo.startWatchingFileSystem();
}
@ -279,12 +280,15 @@ export class RepositoryNode extends SubscribeableViewNode {
private formatLastFetched(options: { prefix?: string; format?: string } = {}) {
if (this._lastFetched === 0) return '';
if (options.format === undefined && Date.now() - this._lastFetched < Dates.MillisecondsPerDay) {
return `${options.prefix || ''}${Dates.toFormatter(new Date(this._lastFetched)).fromNow()}`;
if (options.format === undefined && Container.config.defaultDateStyle === DateStyle.Relative) {
// If less than a day has passed show a relative date
if (Date.now() - this._lastFetched < Dates.MillisecondsPerDay) {
return `${options.prefix || ''}${Dates.toFormatter(new Date(this._lastFetched)).fromNow()}`;
}
}
return `${options.prefix || ''}${Dates.toFormatter(new Date(this._lastFetched)).format(
options.format || 'MMM DD, YYYY'
options.format || Container.config.defaultDateShortFormat || 'MMM D, YYYY'
)}`;
}

Зареждане…
Отказ
Запис