File tree Expand file tree Collapse file tree 4 files changed +28
-0
lines changed
continuous_delivery_scripts Expand file tree Collapse file tree 4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ def _clean_repository() -> None:
103103 """Cleans the local repository."""
104104 with LocalProjectRepository () as git :
105105 logger .info ("Cleaning repository" )
106+ git .stash ()
106107 git .clean ()
107108 git .fetch ()
108109 git .pull ()
Original file line number Diff line number Diff line change @@ -493,6 +493,13 @@ def clean(self) -> None:
493493 if self .is_dirty ():
494494 self .repo .git .clean (force = True , x = True , d = True )
495495
496+ def stash (self ) -> None :
497+ """Stashes the repository.
498+
499+ Performs a stash.
500+ """
501+ self .repo .git .stash (all = True , quiet = True )
502+
496503 def configure_for_github (self ) -> None :
497504 """Reconfigures the repository.
498505
Original file line number Diff line number Diff line change 1+ Added a stash repository step
Original file line number Diff line number Diff line change @@ -105,6 +105,25 @@ def test_repo_clean(self):
105105 uncommitted_changes = clone .uncommitted_changes
106106 self .assertTrue (len (uncommitted_changes ) == 0 )
107107
108+ def test_repo_stash (self ):
109+ """Test basic git clean on the clone."""
110+ with ProjectTempClone (desired_branch_name = "main" ) as clone :
111+ branch = clone .create_branch (f"test-{ uuid4 ()} " )
112+ clone .checkout (branch )
113+ self .assertTrue (len (clone .list_files_added_on_current_branch ()) == 0 )
114+ test_file1 = Path (clone .root ).joinpath (f"branch-test-{ uuid4 ()} .txt" )
115+ test_file1 .touch ()
116+ test_file2 = Path (clone .root ).joinpath (f"branch-test-{ uuid4 ()} .txt" )
117+ test_file2 .touch ()
118+ clone .add (test_file2 )
119+ uncommitted_changes = clone .uncommitted_changes
120+ self .assertTrue (test_file1 in uncommitted_changes )
121+ self .assertTrue (clone .is_dirty ())
122+ clone .stash ()
123+ self .assertFalse (clone .is_dirty ())
124+ uncommitted_changes = clone .uncommitted_changes
125+ self .assertTrue (len (uncommitted_changes ) == 0 )
126+
108127 def test_file_addition_with_paths_to_initial_repository (self ):
109128 """Test basic git add on the clone."""
110129 git = ProjectGitWrapper ()
You can’t perform that action at this time.
0 commit comments