-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can it detect the projects in some folders automatically? #65
Comments
See if I understand you correctly: right now Project Manager only use the first folder from the sidebar to name the project, you are requesting the feature that using the folder which containing |
Yes, but detect the sub-directories of the folders we indicate. For instance, there are two options, {
"git-folders": [
"/path/to/folder1",
"/path/to/folder2"
],
"svn-folders": [
"/path/to/folder3",
"/path/to/folder4",
]
} In the folder The algorithm is as follows.
For The plugin maybe have a command, which will execute the algorithm above automatically when we trigger it. So we will get all that we want. |
Sublime Text only understands project via |
I know. But it may not be executed frequently, only when to trigger it. Once having detected, it's ok. What's more, it's not necessary to detected them frequently or each time when ST starts. In general, moreover, we don't have thousands of git/svn projects, just When found some git/svn projects, if it hasn't existed in ST projects, just create a ST project; or just update the ST project path when the git/svn path is not the same as the project path in |
Actually I quite like your idea, but there are a few things that I need to think about. For example, how happen if one of the folders containing git repos is removed? As the corresponding ST project files were created, shall we just leave them in the I am leaning to the idea of |
About the 1st issue, we can solve it by an option in configuration file. If true, remove it; or leave. The idea of |
|
I just run this script when I want to generate the project folders: import glob
import json
import socket
import sys
import os
def print_usage():
print('Usage: [PATH_OF_GIT_PROJECTS]')
def create_new_project(sublime_projects_path, folder_path):
project_name = os.path.basename(folder_path)
data = {
"folders": [
{
"binary_file_patterns": [],
"file_exclude_patterns": [],
"folder_exclude_patterns": [],
"name": project_name,
"path": folder_path,
}
]
}
print('Creating new sublime project for: {}'.format(project_name))
project_path = os.path.join(sublime_projects_path, '{}.sublime-project'.format(project_name))
with open(project_path, 'w') as file:
json.dump(data, file, indent=2)
def get_current_projects(sublime_projects_path):
os.chdir(sublime_projects_path)
projects = []
for file in glob.iglob('*.sublime-project'):
try:
file_path = os.path.join(sublime_projects_path, file)
data = json.load(open(file_path))
if 'folders' in data:
data['__project_path'] = file_path
projects.append(data)
except Exception as e:
print('Error while getting current projects: {}'.format(e))
sys.exit(1)
return projects
def detect_new_git_folders(path_to_check):
folders = set()
for file in os.listdir(path_to_check):
try:
file_path = os.path.join(path_to_check, file)
if '.git' in os.listdir(file_path):
folders.add(os.path.expanduser(file_path))
except:
pass
return folders
def main():
if len(sys.argv) < 2:
print_usage()
sys.exit(1)
path_to_check = sys.argv[1]
sublime_projects_path = os.path.expanduser('~/.config/sublime-text-3/Packages/User/Projects - {}/'.format(socket.gethostname()))
current_folders = { folder['path'] for project in get_current_projects(sublime_projects_path) for folder in project['folders'] }
detected_folders = detect_new_git_folders(path_to_check)
for folder_path in sorted(detected_folders - current_folders):
create_new_project(sublime_projects_path, folder_path)
if __name__ == "__main__":
main() I also have another script which "prunes" the projects: it checks all the I think this kind of functionality would be nice to have in this package. @randy3k would you be open to a Pull Request to add this functionality in? 🤔 |
I actually just wrote a similar script today as @acheronfail before finding this enhancement request. I too would love this functionality in Project Manager. It could be baked into the "Refresh Projects" action and look in a list of defined repository root directories defined in settings. |
The plugin of Visual Studio Code, Project Manager, can detect the
git
orsvn
projects when i indicate a list of folders. I think it is very intelligent, and this plugin maybe add this feature.The text was updated successfully, but these errors were encountered: