Skip to content

Add support for remote creation#19

Closed
jiaxinnns wants to merge 3 commits intogit-mastery:mainfrom
jiaxinnns:feature/include-remote-repo
Closed

Add support for remote creation#19
jiaxinnns wants to merge 3 commits intogit-mastery:mainfrom
jiaxinnns:feature/include-remote-repo

Conversation

@jiaxinnns
Copy link
Copy Markdown
Contributor

@jiaxinnns jiaxinnns commented Jan 19, 2026

This PR adds a new parameter, include_remote_repo, to the create_repo_smith function. When set to True, repo-smith creates temporary directory in the user's system and initialises a bare git repository in it.

create_repo_smith now returns a tuple of 2 RepoSmith objects, one representing the local repository and one representing the remote repository (if any).

Fixes #18

Copy link
Copy Markdown

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 adds support for creating remote repositories during test setup by introducing a new include_remote_repo parameter to the create_repo_smith function. When enabled, a bare git repository is created and configured as the "origin" remote, allowing tests to simulate push workflows.

Changes:

  • Added include_remote_repo boolean option to CreateRepoOptions TypedDict
  • Implemented logic to create a temporary bare git repository and configure it as the "origin" remote when include_remote_repo=True
  • Added cleanup logic to remove the temporary bare repository after the context manager exits

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

if repo is not None:
repo.git.clear_cache()
shutil.rmtree(dir)

Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Trailing whitespace on this line should be removed to maintain code consistency and follow Python style guidelines.

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +74
if include_remote_repo:
local_remote_dir = tempfile.mkdtemp()
remote_path = os.path.join(local_remote_dir, "remote.git")
Repo.init(remote_path, bare=True)
repo.create_remote("origin", remote_path)
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The new include_remote_repo functionality lacks test coverage. Since other parts of the codebase have comprehensive test coverage (as seen in the tests/integration directory), this new behavior should have corresponding tests to verify that the remote repository is correctly created and cleaned up.

Copilot uses AI. Check for mistakes.
repo = Repo.clone_from(clone_from, dir)
else:
repo = Repo.init(dir, initial_branch="main")

Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Trailing whitespace on this line should be removed to maintain code consistency and follow Python style guidelines.

Copilot uses AI. Check for mistakes.
@jiaxinnns jiaxinnns closed this Jan 23, 2026
@jiaxinnns
Copy link
Copy Markdown
Contributor Author

Closed as introducing change at exercises repository instead

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.

Add support for remote creation

2 participants