refactor: rename convertToInclude setting

This commit is contained in:
shumadrid 2025-04-07 10:28:36 +02:00
parent 7302642bcb
commit 790fc02936
8 changed files with 69 additions and 17 deletions

View file

@ -4,6 +4,26 @@ A new [Obsidian](https://obsidian.md) plugin that utilizes Git commit history to
![Showcase](.github/showcase.gif)
## Table of Contents
- [Installation](#installation)
- [Features](#features)
- [Vault Changelog View](#vault-changelog-view)
- [File Changelog View](#file-changelog-view)
- [Changelog Customizability](#changelog-customizability)
- [Live Stats in the Status Bar for the Current Note](#live-stats-in-the-status-bar-for-the-current-note)
- [Integration with Git Plugin's Diff View](#integration-with-git-plugins-diff-view)
- [Data Loss Monitoring](#data-loss-monitoring)
- [Common Causes of Data Loss](#common-causes-of-data-loss)
- [How to Use](#how-to-use)
- [Limitations](#limitations)
- [Roadmap](#roadmap)
- [Alternatives](#alternatives)
- [FAQ](#faq)
- [Debugging](#debugging)
- [Contributing](#contributing)
- [Credits](#credits)
## Installation
Install the plugin from [the official Community Plugins repository](https://obsidian.md/plugins?id=git-changelog).
@ -22,6 +42,7 @@ Install the plugin from [the official Community Plugins repository](https://obsi
- Shows the total count of lines added and deleted.
- Displays counts of files added, modified, deleted, and moved/renamed (total or text and non-text separately). If a file is both renamed/moved and modified, it will contribute towards the renamed files stats.
- Lists per file lines added and deleted, along with additional file statuses (**A**dded, **R**enamed, **M**oved, or **D**eleted).
- The files are sorted from most number of lines changed to least.
- **Exclude Files and Folders:**
Usually you specify files and folders you want to exclude from your Git repository in the `.gitignore` file.
@ -30,7 +51,7 @@ Install the plugin from [the official Community Plugins repository](https://obsi
But this setting is useful if you want to keep some files backed up by your repository (e.g. because they're valuable), but exclude them from appearing in the vault changelog.
Common examples for this: `.trash` and `.obsidian` folders, debug/log files, or conflict files generated by a syncing service that can clutter the changelog stats.
Common examples for this: `/.trash`, `/attachments` and `/.obsidian` folders, debug/log files, or conflict files generated by a syncing service that can clutter the changelog stats.
Also use this setting to filter files and folders that already exist in previous commits, since specifying files in .gitignore doesn't remove them from previous commits.
@ -38,6 +59,14 @@ Install the plugin from [the official Community Plugins repository](https://obsi
For advanced users: If you configured your Git repository to be below the vault root directory, the paths should be relative to the Git repo, not the vault.
- **Include items:**
Convert the `Exclude Files and Folders` list to an include list, while excluding everything else.
An example case where this can come in handy is when you notice your vault misbehaving, you can trigger this setting and put `.obsidian` in the list to exclusively see changes made inside your configuration folder.
Then you can easily investigate what settings recently changed and if some of the changes are the cause of your issue.
![Vault Changelog View](.github/vault-changelog-view.webp)
### File Changelog View
@ -53,7 +82,7 @@ Install the plugin from [the official Community Plugins repository](https://obsi
- Set a custom day start time (if you're a night owl and want to track your actual days).
- Set a custom timezone to base the intervals on or detect it automatically.
- Choose to view hourly, daily, weekly, or monthly intervals.
- Easily switch between hourly, daily, weekly, and monthly intervals.
- Choose from 5 options to ignore whitespace changes with varying intensity.
- **Adjust file rename detection strictness:**
@ -150,15 +179,22 @@ If you don't want to depend on Git, check out the [Vault Changelog](https://gith
## FAQ
### Will this plugin alter my Git repository/config?
- Will this plugin alter my Git repository/config?
- No. This plugin is intended to be read-only and does not alter any Git configurations.
However, it's in beta, so bugs are possible.
- No. This plugin is intended to be read-only and does not alter any Git configurations. However, it's in beta, so bugs are possible.
### I have been using Obsidian for some time but don't have a Git repo set up. Can I still use this plugin to view the history of my vault?
The only exception is if you explicitly click the `Apply` button for the `Difference detection algorithm` setting, which applies the selected algorithm to the `.git/config` file.
- I have been using Obsidian for some time but don't have a Git repo set up. Can I still use this plugin to view the history of my vault?
- No. 😔
- After making substantial changes, the plugin is showing unusual stats.
- Try disabling all exclusion rules and see if it was some rule that was influencing the stats.
Example scenario: A folder that was marked as excluded is now moved to a different location, the existing rule no longer affects that folder, so the plugin is showing the files inside that folder as added instead of moved.
## Debugging
By default, debug messages for this plugin are hidden. They aren't intended for the user.

View file

@ -89,7 +89,8 @@ export default typescriptEslint.config(
'error',
{
ignore: [-1, 0, 1, 2],
ignoreDefaultValues: true
ignoreDefaultValues: true,
ignoreClassFieldInitialValues: true
}
],
'@typescript-eslint/explicit-function-return-type': [

View file

@ -106,8 +106,16 @@ export class GitChangelogPlugin extends PluginBase<GitChangelogPluginSettings> {
this.consoleDebug(`Error:`, error.stack);
}
public displayNotice(
message: DocumentFragment | string,
// eslint-disable-next-line no-magic-numbers
public displayNotice(message: string, timeout: number = 3 * 1000): void {
timeout: number = 3 * 1000
): void {
if (message instanceof DocumentFragment) {
new Notice(message, timeout);
return;
}
new Notice(`${this.manifest.name}:\n${message}`, timeout);
}

View file

@ -70,8 +70,8 @@ export class VaultChangelogManager extends ChangelogManager<VaultChangelogEntry>
return true;
}
if (
oldSettings.vaultChangelogGenerationSettings.convertToInclude !==
newSettings.vaultChangelogGenerationSettings.convertToInclude
oldSettings.vaultChangelogGenerationSettings.convertToIncludeList !==
newSettings.vaultChangelogGenerationSettings.convertToIncludeList
) {
return true;
}

View file

@ -76,7 +76,7 @@ export async function runRepoDiff({
const pathSpec = convertGitIgnoreToPathspec(
plugin.settings.vaultChangelogGenerationSettings
.excludeFilesAndFoldersLines,
plugin.settings.vaultChangelogGenerationSettings.convertToInclude
plugin.settings.vaultChangelogGenerationSettings.convertToIncludeList
);
const numstatArguments = [

View file

@ -117,7 +117,14 @@ export function addExcludeMenuItem({
plugin
});
const ruleAlreadyExists = lineNumber !== -1;
const actionTitle = ruleAlreadyExists ? 'Reinclude' : 'Exclude';
const isIncludeList =
plugin.settings.vaultChangelogGenerationSettings.convertToIncludeList;
let actionTitle: string;
if (isIncludeList) {
actionTitle = ruleAlreadyExists ? 'Re-exclude' : 'Include';
} else {
actionTitle = ruleAlreadyExists ? 'Reinclude' : 'Exclude';
}
item
.setSection('action')

View file

@ -35,7 +35,7 @@ export interface ChangelogGenerationSettings {
export interface VaultChangelogGenerationSettings {
excludeFilesAndFoldersLines: string[];
convertToInclude: boolean;
convertToIncludeList: boolean;
interval: ChangelogInterval;
}
@ -120,7 +120,7 @@ export class GitChangelogPluginSettings
export const DEFAULT_VAULT_CHANGELOG_GENERATION_SETTINGS: VaultChangelogGenerationSettings =
{
excludeFilesAndFoldersLines: [],
convertToInclude: false,
convertToIncludeList: false,
interval: ChangelogInterval.Daily
} as const;

View file

@ -26,7 +26,7 @@ export class IncludeItemsToggle extends GitChangelogSetting {
toggle
.setValue(
this.plugin.settings.vaultChangelogGenerationSettings
.convertToInclude
.convertToIncludeList
)
.onChange((value) => {
const newSettings = this.plugin.settingsClone;