jacebrowning / jacebrowning/gitman

Detect changes in remote repositories when listing dependencies

Open
#302 4 comments 0 reactions 0 assignees View on GitHub
feature help wanted
Dominant language
Python
Stars
225
Forks
36
Avg merge
15h 47m
Merged PRs (30d)
8

Description

I would like Gitman to be able to detect changes/committed changes in dependency repositories as changes are often implemented directly within the project for testing when using the dependency repository as a submodule.

I have an example of `gitman.yaml`

```yaml
location: .gitman
sources:
- repo: https://[org]@dev.azure.com/[org]/[project]/_git/[repo]
name: utils
rev: main
type: git
params:
sparse_paths:
-
links:
- source: ''
target: .config
- source: .pre-commit-config.yaml
target: .pre-commit-config.yaml
```

Assume I am making a change directly in the `.pre-commit-config.yaml` in the root project then I expect `git` to detect the changes/commited changes as they do for git submodules.

```sh
cd .gitman/utils
gitman list --fail-if-dirt # OK

echo '#' >> .pre-commit-config.yaml
gitman list --fail-if-dirt # Uncommitted changes

git add .pre-commit-config.yaml
gitman list --fail-if-dirt # Uncommitted changes

git commit -m"test"
gitman list --fail-if-dirt # OK, but it's not OK - the change has not been pushed to remote repo
```

If I run `git status` from the root I also don't see any changes. I would like to have an indication from Gitman that the dependency repository is in state ["Your branch is ahead of 'origin/main' by X commit"](https://stackoverflow.com/questions/20433867/git-ahead-behind-info-between-master-and-branch).

One way to mitigate this would be to configure a git alias `alias git='f(){ if ! gitman list --fail-if-dirt > /dev/null; then gitman list --fail-if-dirt; fi; git "$@"; unset -f f; }; f'` to make sure this command is executed before any `git` commands. However, this will not capture the committed changes. This command also returns exit code 0 even though ´gitman` returns an error. I would expect exit code 1.

If this is not resolved I am affraid that users will forget that they made any changes to a dependency project and suddenly a lot of changes might be missed and forgotten.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the `gitman list --fail-if-dirt` command and the Git dependency handling for entries configured in `gitman.yaml`. Reproduce the example with a local dependency commit ahead of its remote branch; done means Gitman reports the unpushed committed change and returns a failing exit code when requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.