Skip to content

[Feature] Track unstaged local Git changes by default #268

Closed

Description

@peterschmidt85
  1. By default, include unstaged changes.
  2. Allow listing paths to exclude local changes via .dstackignore (similar to .gitignore).

Activity

  1. converted this from a draft issue on Mar 23, 2023
  2. moved this from Backlog to Considering in Roadmapon Mar 23, 2023
  3. moved this from Considering to Backlog in Roadmapon Apr 9, 2023
  4. Egor-S commented on May 9, 2023

    @Egor-S
    Contributor

    As I understand, unstaged changes are included in the diff patch. There is a problem with untracked files. But since they weren't seen by the git — diff for them is simply all “add“ lines with a header.

    git diff format reference: https://git-scm.com/docs/diff-format

  5. peterschmidt85 commented on May 9, 2023

    @peterschmidt85
    ContributorAuthor

    @Egor-S As far as I know unstaged and untracked is the same thing. I meant untracked.
    Do you mean we could simply include untracked files ourselves into repo_diff?

  6. Egor-S commented on May 10, 2023

    @Egor-S
    Contributor

    I just tried: to create a completely new file, to edit an existing file without git add, and to edit an existing file but with git add. There is the output:

    egors:~/dstack/hello-world-local/.dstack/workflows 🚀 git status      
    On branch dev
    Your branch is ahead of 'origin/dev' by 1 commit.
      (use "git push" to publish your local commits)
    
    Changes to be committed:
      (use "git restore --staged <file>..." to unstage)
            modified:   ssh.yaml
    
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git restore <file>..." to discard changes in working directory)
            modified:   hello.yaml
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
            new-untracked.yaml
    

    Both ssh.yaml and hello.yaml appear in git.Repo().git.diff(remote_hash)


    Yes, I think it would be pretty easy to handcraft diff patches for new files. We should replicate the output of git diff --no-index /dev/null {file}. Possible template:

    diff --git a/{file} b/{file}
    new file mode 100{oct_filemode}
    index 0000000..{some 7 hex-chars?}
    --- /dev/null
    +++ b/{file}
    @@ -0,0 +1,{len(lines)} @@
    +{lines[0]}
    +{lines[1]}
    ...
    +{lines[-1]}
    
  7. self-assigned this
    on May 10, 2023
  8. Egor-S commented on May 10, 2023

    @Egor-S
    Contributor

    Implemented in #388

  9. moved this from Backlog to Released in Roadmapon May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions