Skip to content

Commit

Permalink
add --share-objects option, with this option will share ~/.project-ob…
Browse files Browse the repository at this point in the history
…jects for current user
  • Loading branch information
zhangchunlin committed Jul 12, 2018
1 parent da40341 commit 0c16efd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions repo
Expand Up @@ -212,6 +212,9 @@ group.add_option('--no-clone-bundle',
group.add_option('--no-tags',
dest='no_tags', action='store_true',
help="don't fetch tags in the manifest")
group.add_option('--share-objects',
dest='share_objects', action='store_true',
help='share project-objects in the ~/.project-objects for current user')


# Tool
Expand Down Expand Up @@ -338,6 +341,15 @@ def _Init(args, gitc_init=False):
return

os.mkdir(repodir)
if opt.share_objects:
share_project_objects_dir = os.path.expanduser("~/.project-objects")
if not os.path.exists(share_project_objects_dir):
_print('make dir: %s'%(share_project_objects_dir))
os.makedirs(share_project_objects_dir)
project_objects_dir = os.path.join(repodir,"project-objects")
if not os.path.exists(project_objects_dir) and os.path.isdir(share_project_objects_dir):
_print('make symbol link %s to %s'%(project_objects_dir,share_project_objects_dir))
os.symlink(share_project_objects_dir,project_objects_dir)
except OSError as e:
if e.errno != errno.EEXIST:
_print('fatal: cannot make %s directory: %s'
Expand Down
3 changes: 3 additions & 0 deletions subcmds/init.py
Expand Up @@ -130,6 +130,9 @@ def _Options(self, p):
g.add_option('--no-tags',
dest='no_tags', action='store_true',
help="don't fetch tags in the manifest")
g.add_option('--share-objects',

This comment has been minimized.

Copy link
@yudenzel

yudenzel Aug 12, 2020

maybe we can make this option to accept a user-provided path, and enable it when it's a directory so that the user can specify different locations instead of "~/.project-objects".

This comment has been minimized.

Copy link
@zhangchunlin

zhangchunlin Aug 13, 2020

Author Owner

This is just an enhancement, but the whole method didn't work at that time when I do some actual test: https://groups.google.com/g/gotgit/c/mqXTNvyXgj8 @yudenzel

dest='share_objects', action='store_true',
help='share project-objects in the ~/.project-objects for current user')

# Tool
g = p.add_option_group('repo Version options')
Expand Down

1 comment on commit 0c16efd

@mamh2021
Copy link

Choose a reason for hiding this comment

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

好使吗这个?
我的想法是 手动 建个 link 到 .repo/.project-objects 下, 每套代码的下面的.repo/.project-objects 都软连接到 ~/.project-objects , 然后在repo init 最后repo sync. 你这个是 直接在代码里面 做了是吧.

之前都是用的 --reference的.

Please sign in to comment.