Skip to content

Conversation

@hovu96
Copy link
Contributor

@hovu96 hovu96 commented Oct 27, 2025

Summary

Fixes false "directory not empty" warning that appears when running workato init in a newly created directory.

Problem

When initializing a project with workato init, the CLI shows an incorrect warning:

⚠️ Directory '<path>' is not empty. Proceed with initialization? [y/N]

This warning appears even though the directory was just created by the CLI itself. The issue occurs because:

  1. ConfigManager.initialize() creates the project directory and .workatoenv file
  2. The emptiness check runs after initialization and detects .workatoenv
  3. The check doesn't distinguish between CLI-created files and user files

Solution

Modified the directory emptiness check in init.py to filter out CLI-managed files before determining if a directory contains user files.

CLI-managed files (now ignored):

  • .workatoenv - Configuration file
  • .gitignore - Git ignore patterns
  • .workato-ignore - Workato ignore patterns

Changes:

  • Added cli_managed_files set to define files that should be ignored
  • Changed from any(project_dir.iterdir()) to checking only non-CLI-managed files
  • Ensures warnings only appear for actual user files

Benefits

✅ No false warnings during clean initialization
✅ Legitimate warnings still work for user files
✅ Supports idempotent re-initialization
✅ Enables recovery from partial initialization
✅ No breaking changes

Test Plan

Added 4 comprehensive unit tests:

  1. test_init_cli_managed_files_ignored_interactive - Verifies CLI files ignored in interactive mode
  2. test_init_cli_managed_files_ignored_non_interactive - Verifies CLI files ignored in non-interactive mode
  3. test_init_user_files_with_cli_files_triggers_warning - Ensures user files still trigger warnings
  4. test_init_only_workatoenv_file_ignored - Tests most common case (only .workatoenv present)

Coverage: 100% of changed code
Results: All 21 init tests passing

Files Changed

  • src/workato_platform/cli/commands/init.py - 11 lines modified
  • tests/unit/commands/test_init.py - 246 lines added (4 new tests)

Manual Testing

Manually tested the following scenarios:

  • workato init with new directory - No false warning
  • workato init with existing empty directory - No warning
  • workato init with existing non-empty directory - Appropriate warning shown
  • workato init re-run in same directory - No false warning for CLI-managed files

🤖 Generated with Claude Code

Modified the directory emptiness check to filter out CLI-managed files
(.workatoenv, .gitignore, .workato-ignore) before determining if a
directory contains user files. This prevents false warnings when the CLI
creates these files during initialization.

The check now distinguishes between:
- CLI-managed files (should be ignored)
- User files (should trigger warning)

This enables:
- Clean initialization without false warnings
- Idempotent re-initialization support
- Recovery from partial initialization

Added 4 comprehensive tests covering:
- Interactive mode with CLI-managed files only
- Non-interactive mode with CLI-managed files only
- User files mixed with CLI-managed files (warning still triggered)
- Most common case (only .workatoenv present)

All 21 init tests passing, 100% coverage of changed code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Oct 27, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py62296%12–13
cli
   __init__.py52394%49, 51, 60
   containers.py270100% 
cli/commands
   __init__.py00100% 
   api_clients.py286996%24, 297, 442–443, 476, 486, 576, 607, 615
   api_collections.py253398%25, 178, 340
   assets.py46295%51–52
   connections.py520599%578, 580, 586, 624, 973
   data_tables.py163596%28, 248, 262, 316–317
   guide.py166199%106
   init.py890100% 
   profiles.py1970100% 
   properties.py95198%18
   pull.py171298%190–191
   workspace.py38294%57, 67
cli/commands/connectors
   __init__.py00100% 
   command.py88297%103, 152
   connector_manager.py203498%176, 292, 300–301
cli/commands/projects
   __init__.py00100% 
   command.py2691096%353–356, 367, 433–435, 485, 489
   project_manager.py166795%48, 66, 263–264, 276, 317, 325
cli/commands/push
   __init__.py00100% 
   command.py132496%101, 104, 222, 300
cli/commands/recipes
   __init__.py00100% 
   command.py423997%113, 129–130, 267–270, 397, 703
   validator.py7062097%174, 883, 1136, 1223, 1246, 1279, 1281–1282, 1359–1361, 1457–1458, 1517–1518, 1707–1708, 1736–1738
cli/utils
   __init__.py30100% 
   exception_handler.py198696%137, 184, 211, 238, 295, 330
   gitignore.py140100% 
   ignore_patterns.py230100% 
   spinner.py430100% 
   version_checker.py135695%24, 26, 33–34, 72, 102
cli/utils/config
   __init__.py50100% 
   manager.py4671995%125, 136–138, 141, 154, 204–205, 357, 438–439, 478, 692, 835–836, 850–851, 912, 971
   models.py330100% 
   profiles.py3091096%93, 189–190, 193, 228–230, 255–257
   workspace.py680100% 
TOTAL545013297% 

@hovu96 hovu96 requested a review from oalami October 27, 2025 10:18
@hovu96 hovu96 self-assigned this Oct 27, 2025
@oalami oalami requested a review from Copilot October 27, 2025 19:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a false "directory not empty" warning that incorrectly appears when running workato init in a directory containing only CLI-managed configuration files. The issue occurred because the emptiness check didn't distinguish between files created by the CLI itself (like .workatoenv) and actual user files.

Key Changes:

  • Modified the directory emptiness check to filter out CLI-managed files (.workatoenv, .gitignore, .workato-ignore)
  • Added logic to only warn users when actual user files are present in the directory
  • Added comprehensive test coverage for various initialization scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/workato_platform/cli/commands/init.py Updated emptiness check to exclude CLI-managed files from consideration
tests/unit/commands/test_init.py Added 4 new test cases covering CLI file handling and fixed lambda signatures in existing tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

oalami and others added 2 commits October 27, 2025 12:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@oalami oalami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Applied some Copilot suggested fixes, you'll need to review and merge. @hovu96

…new-project-directory-is-not-empty-after-init
@hovu96 hovu96 merged commit 354e413 into main Oct 28, 2025
5 checks passed
@hovu96 hovu96 deleted the Incorrect-warns-that-new-project-directory-is-not-empty-after-init branch October 28, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants