コード例 #1
0
ファイル: pb.py プロジェクト: jrdavid/pb
 def import_project(self, directory):
     project_name = os.path.basename( directory )
     if project_name in self.projects:
         print("A project named '{0}' already exists.".format(project_name))
         sys.exit(1)
     # Create project entry in database
     new_pb_project = Project(project_name, self, None)
     # Copy files
     shutil.copytree( directory, new_pb_project.work_dir)
     original_dir = os.getcwd()
     print("Creating public git repo '{0}'".format(new_pb_project.public_dir))
     os.makedirs( new_pb_project.public_dir )
     original_dir = os.getcwd()
     os.chdir(new_pb_project.public_dir)
     git.init(True)
     os.chdir(new_pb_project.work_dir)
     # Initialize git repo if it doesn't exist
     if not os.path.isdir(".git"):
         # Create first import with initial content
         git.init(False)
         git.add(["."])
         git.commit("Import from {0}.".format(directory))
     # Create public repository
     if 'public' in git.remote_list():
         print("Renaming old public repo to public.orig")
         git.remote_rename('public', 'public.orig')
     print("Adding 'public' remote")
     git.remote_add("public", new_pb_project.public_dir)
     os.chdir( original_dir )
     # Open by default
     self.projects[project_name] = new_pb_project
     new_pb_project.state = "open"
     # why save? -> to update the state to 'open'
     new_pb_project.save()
コード例 #2
0
ファイル: pb.py プロジェクト: jrdavid/pb
 def import_project(self, options ):
     if not os.path.isdir(self.work_path):
         print("No directory named '{0}' exist in '{1}'.".format(
                 self.name, options.work))
         sys.exit(1)
     os.chdir(self.work_path)
     if not os.path.isfile( os.path.join( self.work_path, ".git" ) ):
         git.init(False)
     remotes = git.remote_list()
     if "public" not in remotes:
         git.remote_add("public", self.public_path)
     if not os.path.isdir( self.public_path ):
         os.makedirs( self.public_path )
         os.chdir( self.public_path )
         git.init(True)
     self.state = "open"
コード例 #3
0
ファイル: pb.py プロジェクト: jrdavid/pb
 def check(self, directories):
     print("Directory\tVCS\tPublic repo")
     for directory in directories:
         original_dir = os.getcwd()
         if original_dir == self.root and directory == 'public':
             continue
         if not os.path.isdir( directory ):
             continue
         try:
             os.chdir(directory)
         except OSError:
             continue
         version_control = "n/a"
         public_repo     = "n/a"
         if os.path.isdir(".git"):
             version_control = "git"
             if 'public' in git.remote_list():
                 public_repo = "yes"
             else:
                 public_repo = "no"
         print("{0}\t{1}\t{2}".format(directory, version_control, public_repo))
         os.chdir(original_dir)