Skip to content

Add include_uncommitted and include_untracked options to GitArchivePackager#211

Closed
oliverholworthy wants to merge 4 commits intoNVIDIA-NeMo:mainfrom
oliverholworthy:oholworthy/git-packager-include-unstaged-untracked
Closed

Add include_uncommitted and include_untracked options to GitArchivePackager#211
oliverholworthy wants to merge 4 commits intoNVIDIA-NeMo:mainfrom
oliverholworthy:oholworthy/git-packager-include-unstaged-untracked

Conversation

@oliverholworthy
Copy link

This PR adds two new features to the GitArchivePackager:

  • include_uncommitted: Option to include uncommitted changes in the packaged archive
  • include_untracked: Option to include untracked files in the packaged archive

Purpose

By default, git archive only includes committed files in the specified Git reference. These new options allow users to package their working state including uncommitted changes and untracked files, which is useful for development and testing scenarios where the user wants to package their current work-in-progress state.

Features

include_uncommitted

When set to True, uncommitted changes to tracked files will be included in the archive. This captures modifications that haven't been committed yet.

# Example: Include uncommitted changes
packager = GitArchivePackager(ref="HEAD", include_uncommitted=True)

include_untracked

When set to True, untracked files will be included in the archive. This captures new files that haven't been added to git yet.

# Example: Include untracked files
packager = GitArchivePackager(ref="HEAD", include_untracked=True)

Combined usage

Both options can be used together to capture the complete working state:

# Example: Include both uncommitted changes and untracked files
packager = GitArchivePackager(
    ref="HEAD", 
    include_uncommitted=True, 
    include_untracked=True
)

Implementation Details

  • Implemented using git diff --name-only to find uncommitted changes
  • Implemented using git ls-files --others --exclude-standard to find untracked files
  • Works correctly with the subpath option, only including uncommitted/untracked files within the specified subpath
  • Compatible with both Linux and non-Linux platforms

Testing

Added comprehensive tests to verify all functionality:

  • Test for uncommitted changes only
  • Test for untracked files only
  • Test for both uncommitted and untracked together
  • Test with subpath to verify path handling

Signed-off-by: Oliver Holworthy <oholworthy@nvidia.com>
ctx.run(f"tar -cf {unstaged_tar_file} {' '.join(changed_files)}")
else:
# Create empty tar file to avoid errors
ctx.run(f"tar -cf {unstaged_tar_file} --files-from /dev/null")

Check warning

Code scanning / CodeQL

Unreachable code Warning

This statement is unreachable.
Signed-off-by: Oliver Holworthy <oholworthy@nvidia.com>
Signed-off-by: Oliver Holworthy <oholworthy@nvidia.com>
Signed-off-by: Oliver Holworthy <oholworthy@nvidia.com>
@oliverholworthy oliverholworthy marked this pull request as draft April 22, 2025 11:03
@github-actions
Copy link
Contributor

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 24, 2025
@github-actions
Copy link
Contributor

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant