By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Subdomains

roundabout,
created on Sunday, 28 April 2024, 11:06:04 (1714302364), received on Wednesday, 31 July 2024, 06:54:47 (1722408887)
Author identity: vlad <vlad.muntoiu@gmail.com>

76372d71974a7f83fd6580cad019e00d9c3fefa2

.gitignore

@@ -1 +1,3 @@

                                
                                
                                
                            
                                
                                    
                                        
                                        repos/**
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        repos/**
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        usersites/**
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        userdata/**
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

celery_tasks.py

@@ -90,18 +90,18 @@ def merge_heads(head_route, head_branch, base_route, base_branch, simulate=True)

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            @shared_task(ignore_result=False)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            def copy_site(route):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                from models import Repo
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            # Create the site directory if it doesn't exist.
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if not os.path.isdir(os.path.join(config.SITE_PATH, route.rpartition("/")[0].lstrip("/"))):   # create an user directory
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                os.makedirs(os.path.join(config.SITE_PATH, route.rpartition("/")[0].lstrip("/")))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                repo = db.session.get(Repo, route)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                server_repo_location = os.path.join(config.REPOS_PATH, route.lstrip("/"))
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            site_location = os.path.join(config.SITE_PATH, route.lstrip("/"))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            user_location = os.path.join(config.SITE_PATH, route.rpartition("/")[0].lstrip("/"))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if repo.has_site == 2:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                subdomain = repo.owner.username
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            else:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                subdomain = repo.name + "." + repo.owner.username
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            site_location = os.path.join(config.SITE_PATH, subdomain)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                # Get the branch to be used for the site; if it somehow doesn't exist, use the default branch.
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                branch = repo.site_branch or repo.default_branch
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                # Make a shallow clone of the repo; this prevents getting the full git database when it's not needed.
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                if os.path.isdir(site_location):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    # Delete the old site.
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    shutil.rmtree(site_location)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            common.git_command(user_location, b"", "clone", "--depth=1", f"--branch={branch}", os.path.join(os.getcwd(), server_repo_location))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            common.git_command(config.SITE_PATH, b"", "clone", "--depth=1", f"--branch={branch}", os.path.join(os.getcwd(), server_repo_location), subdomain)