Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2ab1bf6
- separated some deeply nested subcommands and grouped everything und…
kimm310 Mar 28, 2025
987d73b
-added help text for each subcommand
kimm310 Mar 28, 2025
e470325
- added subcommands to top-level command "feature" not as apps, but a…
kimm310 Mar 31, 2025
c3f8e12
created manual page
kimm310 Apr 12, 2025
9cc1408
updated README and created html document via pandoc
kimm310 Apr 13, 2025
867d030
created a web doc for git-feature based on the html files residing in…
kimm310 Apr 16, 2025
8cc3ee2
put .1 file and .html file into new directory "helpdoc"
kimm310 Apr 16, 2025
94169af
Merge pull request #1 from kimm310/restructure/subcommands
kimm310 Apr 17, 2025
2ed4ef4
Merge pull request #2 from kimm310/manpage
kimm310 Apr 17, 2025
f308b44
added an executable script so that the user can set the hooks path in…
kimm310 Apr 18, 2025
5059cff
Merge pull request #3 from kimm310/execscripts-for-hooks
kimm310 Apr 20, 2025
62296cc
shows help text when there's no argument for git feature; changed hel…
kimm310 Apr 20, 2025
a56b50f
Merge pull request #4 from kimm310/add-minor-stuff
kimm310 Apr 20, 2025
8aa3196
Funktion gelöscht, die doppelt vorkam: get_features_touched_by_commit
kimm310 Apr 23, 2025
67ac7c4
added usage comments in some feature_data files and repaired run_git_…
kimm310 Apr 23, 2025
6ae3385
implemented the rest of the feature blame steps.
kimm310 Apr 24, 2025
6808576
fixed the missing indentations in the code line display in print_feat…
kimm310 Apr 27, 2025
fefdebd
changed a lot of the logic to make feature blame display the entire i…
kimm310 Apr 30, 2025
8d15d7b
added version restriction for click so that it's compatible with typer
kimm310 May 14, 2025
12750d0
Merge pull request #5 from kimm310/feature/blame
kimm310 May 14, 2025
771814e
added version restriction for click so that it's compatible with typer
kimm310 May 14, 2025
6d86d1f
- typo in README
kimm310 Jun 26, 2025
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
63 changes: 33 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This tool provides advanced Git feature management, allowing you to associate feature information with commits and files.

## Installation + Preaparation
## Installation + Preparation

1. Install the tool using pip:
1. Download the latest release file (currently, the project is not stored in the PIP Index)
Expand All @@ -29,19 +29,19 @@ This tool provides advanced Git feature management, allowing you to associate fe

## Commands Overview

### `git feature-status`
### `git feature status`

Displays the current feature status, including staged, unstaged, and untracked files with their associated features.

**Usage**:
```bash
git feature-status
git feature status
```
### `git feature-add`
### `git feature add`
This command helps to associate feature information with a commit that does not yet exist. You can either add the information while adding the files or add features to the staging area.
If you prefer to keep your workflows as usual and add feature information solely to commits that you already created, you don't need the git hooks and can jump to `git feature-commit`.

#### `git feature-add by-add`
#### `git feature add`

Associates specified features with staged files. You can stage specific files or all tracked changes.

Expand All @@ -51,62 +51,65 @@ Associates specified features with staged files. You can stage specific files or

**Usage**:
```bash
git feature-add by-add --all <feature-names>
git feature-add by-add --files <file>... <feature-names>
git feature add --all <feature-names>
git feature add --files <file>... <feature-names>
```

#### `git feature-add from-staged`
#### `git feature add-from-staged`

Uses staged files to associate them with feature information.

**Usage**:
```bash
git feature-add from-staged
git feature add-from-staged
```


### `git feature-commit`
### `git feature commit`
Assign features to a commit retroactively. To find all commits that have not yet features assigned, see ---
**Usage**:
```bash
git feature-commit <commit> <features>
git feature commit <commit_id> <features>
```

### `git feature-blame`
### `git feature blame`

Displays the feature associations for each line of a specified file, similar to `git blame`.

**Usage**:
```bash
git feature-blame <file>
git feature blame <file>
```

### `git feature-info`
### `git feature info`

Displays detailed information about a feature, including associated commits, files, authors, and branches.

**Options**:
- `--authors`: Lists the authors who contributed to the feature.
- `--files`: Lists the files associated with the feature.
- `--branches`: Lists the branches where the feature is found.
- `--branches`: Lists the branches where the feature is present.
- `--updatable`: Check if the feature has updates available on other branches and list the update options.
- `--branch <branch_name>`: Specify a branch for checking updates (used with `--updatable`).

**Usage**:
```bash
git feature-info <feature>
git feature-info <feature> --authors --files --branches
git feature info <feature>
git feature info <feature> --authors --files --branches
```

### `git feature-commits`
### `git feature commits`

Lists all commits associated with a feature or shows commits that are missing feature associations.

**Options**:
- `--missing`: Lists commits that do not have any associated feature.
**Commands**:
- `missing`: Lists commits that do not have any associated feature.
- `list`: List commits that are associated to features.

**Usage**:
```bash
git feature-commits
git feature-commits --missing
git feature commits list
git feature commits missing
```

---
Expand All @@ -115,38 +118,38 @@ git feature-commits --missing

1. **Check Feature Status**:
```bash
git feature-status
git feature status
```

2. **Add Features to All Files**:
```bash
git feature-add by-add --all "new-feature"
git feature add --all "new-feature"
```

3. **Add Features to Specific Files**:
```bash
git feature-add by-add --files src/main.py "feature-x"
git feature add --files src/main.py "feature-x"
```

4. **Use Staged Files for Feature Information**:
```bash
git feature-add from-staged
git feature add-from-staged
```

5. **Show Feature Associations for a File**:
```bash
git feature-blame src/main.py
git feature blame src/main.py
```

6. **Display Feature Information**:
```bash
git feature-info feature-x --authors --files --branches
git feature info feature-x --authors --files --branches
```

7. **List All Commits With and Without Features**:
```bash
git feature-commits
git feature-commits --missing
git feature commits list
git feature commits missing
```

---
Expand Down
37 changes: 25 additions & 12 deletions git_tool/__main__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import typer
from git_tool.ci.subcommands.feature_add import app as feature_add
from git_tool.ci.subcommands.feature_blame import app as feature_blame
from git_tool.ci.subcommands.feature_commit import app as feature_commit
from git_tool.ci.subcommands.feature_info import app as feature_info
from git_tool.ci.subcommands.feature_status import app as feature_status

app = typer.Typer(name="features")
app.add_typer(feature_add, name="add")
app.add_typer(feature_blame, name="blame")
app.add_typer(feature_commit, name="commit")
app.add_typer(feature_info, name="info")
app.add_typer(feature_status, name="status")

from git_tool.ci.subcommands.feature_add import feature_add_by_add
from git_tool.ci.subcommands.feature_add_from_staged import features_from_staging_area
from git_tool.ci.subcommands.feature_blame import feature_blame
from git_tool.ci.subcommands.feature_commit import feature_commit
from git_tool.ci.subcommands.feature_commit_msg import feature_commit_msg
from git_tool.ci.subcommands.feature_commits import app as feature_commits
from git_tool.ci.subcommands.feature_info import inspect_feature
from git_tool.ci.subcommands.feature_info_all import all_feature_info
from git_tool.ci.subcommands.feature_pre_commit import feature_pre_commit
from git_tool.ci.subcommands.feature_status import feature_status


app = typer.Typer(name="feature", no_args_is_help=True) # "git feature --help" does not work, but "git-feature --help" does
app.command(name="add", help="Stage files and associate them with the provided features.")(feature_add_by_add)
app.command(name="add-from-staged", help="Associate staged files with features.")(features_from_staging_area)
app.command(name="blame", help="Display features associated with file lines.")(feature_blame)
app.command(name="commit", help="Associate an existing commit with one or more features.")(feature_commit)
app.command(name="commit-msg", help="Generate feature information for the commit message.")(feature_commit_msg)
app.add_typer(feature_commits, name="commits", help="Use with the subcommand 'list' or 'missing' to show commits with or without associated features.")
app.command(name="info", help="Show information of a specific feature.")(inspect_feature)
app.command(name="info-all", help="List all available features in the project.")(all_feature_info)
app.command(name="pre-commit", help="Check if all staged changes are properly associated with features.")(feature_pre_commit)
app.command(name="status", help="Display unstaged and staged changes with associated features.")(feature_status)


app()
44 changes: 1 addition & 43 deletions git_tool/ci/subcommands/feature_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
app = typer.Typer(no_args_is_help=True)


@app.command("by-add", no_args_is_help=True)
@app.command("add", help="Stage files and associate them with the provided features.", no_args_is_help=True)
def feature_add_by_add(
feature_names: list[str] = typer.Argument(
None, help="List of feature names to associate with the staged files"
Expand Down Expand Up @@ -52,48 +52,6 @@ def feature_add_by_add(
typer.echo("No features provided.", err=True)


@app.command("from-staged", help="Associate staged files with features")
def features_from_staging_area():
"""
Use the staged files to add feature information.
"""
feature_names = read_features_from_staged()
if feature_names:
typer.echo(f"Features in staging area: {feature_names}")
write_staged_featureset(feature_names)
else:
typer.echo("No features found in staging area.", err=True)


def read_features_from_staged(type: str = "Union") -> list[str]:
"""
Retrieve the features from the current staging area.

Keyword Arguments:
type -- Can be Union or Intersection. Describes how multiple features will be combined (default: {"Union"})

Returns:
List of features.
"""
typer.echo("Using staged files")

staged_files = get_files_by_git_change().get("staged_files", [])
feature_sets = [set(get_features_for_file(f)) for f in staged_files]

if not feature_sets:
return []

if type == "Union":
combined_features = set.union(*feature_sets)
elif type == "Intersection":
combined_features = set.intersection(*feature_sets)
else:
raise ValueError(
"Invalid type specified. Use 'Union' or 'Intersection'."
)

return list(combined_features)


def stage_files(selected_files: list[str]) -> bool:
"""
Expand Down
56 changes: 56 additions & 0 deletions git_tool/ci/subcommands/feature_add_from_staged.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import typer

from git_tool.feature_data.git_status_per_feature import (
get_features_for_file,
get_files_by_git_change,
)
from git_tool.feature_data.models_and_context.feature_state import (
reset_staged_featureset,
write_staged_featureset,
)


app = typer.Typer()


@app.command(name="add-from-staged", help="Associate staged files with features.")
def features_from_staging_area():
"""
Use the staged files to add feature information.
"""
feature_names = read_features_from_staged()
if feature_names:
typer.echo(f"Features in staging area: {feature_names}")
write_staged_featureset(feature_names)
else:
typer.echo("No features found in staging area.", err=True)


def read_features_from_staged(type: str = "Union") -> list[str]:
"""
Retrieve the features from the current staging area.

Keyword Arguments:
type -- Can be Union or Intersection. Describes how multiple features will be combined (default: {"Union"})

Returns:
List of features.
"""
typer.echo("Using staged files")

staged_files = get_files_by_git_change().get("staged_files", [])
feature_sets = [set(get_features_for_file(f)) for f in staged_files]

if not feature_sets:
return []

if type == "Union":
combined_features = set.union(*feature_sets)
elif type == "Intersection":
combined_features = set.intersection(*feature_sets)
else:
raise ValueError(
"Invalid type specified. Use 'Union' or 'Intersection'."
)

return list(combined_features)
Loading