Skip to content
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

add private or public for create repo #152

Closed
wants to merge 4 commits into from
Closed

Conversation

dislazy
Copy link

@dislazy dislazy commented Mar 31, 2022

add private or public for create repo

@Yikun
Copy link
Owner

Yikun commented Mar 31, 2022

Thanks for you contributions!

But in my opinion, this kind of breaks the semantics of synchronization. Could you share your real case? Let's see why we need this parameter. I guess you just want backup your repos but don't want dispaly these repos in your dst hub?

@Yikun
Copy link
Owner

Yikun commented Mar 31, 2022

also cc @yi-Xu-0100 @ShixiangWang @JasonkayZK What do you think?

@ShixiangWang
Copy link

@Yikun Thanks for cc me. Currently I don't have such demands. From the file change, it seems that it would not change default behavior. I agree with you that if a real case can be estimated, it's worthy to have this new option.

@@ -62,7 +63,7 @@ def create_dst_repo(self, repo_name):
if self.dst_type == 'gitee':
data = {'name': repo_name}
Copy link
Owner

Choose a reason for hiding this comment

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

I guess here is my bad before, looks like we could use this in gitee params directly?

README.md Outdated
@@ -50,7 +50,7 @@ steps:
- `debug` 默认为false, 配置后,启用debug开关,会显示所有执行命令。
- `timeout` 默认为'30m', 用于设置每个git命令的超时时间,'600'=>600s, '30m'=>30 mins, '1h'=>1 hours
- `mappings` 源仓库映射规则,比如'A=>B, C=>CC', A会被映射为B,C会映射为CC,映射不具有传递性。主要用于源和目的仓库名不同的镜像。

- `dst_private` 默认为false,配置后,如果gitee仓库不存在,则创建公开仓库,否则创建私有仓库
Copy link
Owner

@Yikun Yikun Mar 31, 2022

Choose a reason for hiding this comment

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

Suggested change
- `dst_private` 默认为false,配置后,如果gitee仓库不存在,则创建公开仓库,否则创建私有仓库
- `dst_visibility` 默认为public,配置为priavte,意味着新创建的仓将默认的设置为私有仓,已存在的仓库则只会进行同步。
  • there are some inconsistent behavior for new creating repo and existing repo, this might not a good enough API for me.
  • dst_private is also not a clear name.

@@ -62,7 +63,7 @@ def create_dst_repo(self, repo_name):
if self.dst_type == 'gitee':
data = {'name': repo_name}
elif self.dst_type == 'github':
data = json.dumps({'name': repo_name})
data = json.dumps({'name': repo_name,'private': self.dst_private})
if not self.has_dst_repo(repo_name):
Copy link
Owner

Choose a reason for hiding this comment

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

as a side note, when second round sync triggered, we can't get this dst private repo, if we enable this private parameter, we will always failed to create the private repo and print Destination repo creating failed:

Copy link
Author

Choose a reason for hiding this comment

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

I don't have similar problems, I now have several private repositories that are github synced to gitee's private repositories

Copy link
Owner

Choose a reason for hiding this comment

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

@dislazy Could you share your workflow yaml link in here? : )

@yi-Xu-0100
Copy link
Contributor

@Yikun Thanks for cc me. If it can be used to release sync the private repo, it will close #38. That will be very nice. 😊

@Yikun
Copy link
Owner

Yikun commented Mar 31, 2022

@yi-Xu-0100 this is not for private repo mirror, it's just for sync public repo as private repo. So let's see the real case from author.

I've heard more than once that wishing the private should be supported, Looks like we should consider supporting private repo mirror. : )

@dislazy
Copy link
Author

dislazy commented Mar 31, 2022

Hello everyone, my main purpose is to achieve mutual backup between github and gitee. If the github repository is private, then if the repository synchronized by gitee is not private, some key information will be leaked.

@Yikun
Copy link
Owner

Yikun commented Mar 31, 2022

@dislazy But private repo mirror haven't been supported yet, we can only get the public repos from src repo list:

def _get_all_repo_names(self, url, page=1):

that means hub-mirror only supports public mirror now.

If the github repository is private,

So, this assumation might be wrong?

@dislazy
Copy link
Author

dislazy commented Apr 1, 2022

As such, yes, but you can continue to optimize

@Yikun
Copy link
Owner

Yikun commented Apr 19, 2022

@dislazy See related commentes in here: #38 (comment)

Could rename dst_private to dst_visibility?

README_en.md Outdated
@@ -47,6 +47,7 @@ More than [100+](https://github.com/search?p=2&q=hub-mirror-action+%22account_ty
- `force_update` (optional) Force to update the destination repo, use '-f' flag do 'git push'
- `timeout` (optional) Default is '30m', set the timeout for every git command, like '600'=>600s, '30m'=>30 mins, '1h'=>1 hours
- `mappings` (optional) Default is empty, the source repos mappings, such as 'A=>B, C=>CC', source repo name would be mapped follow the rule: A to B, C to CC. Mapping is not transitive.
- `dst_private` (optional) Default is false. After configuration, if the gitee repository does not exist, create a public repository, otherwise create a private repository
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
- `dst_private` (optional) Default is false. After configuration, if the gitee repository does not exist, create a public repository, otherwise create a private repository
- `dst_private` (optional) Default is public. If set to `private`, new creating repo visibility is `private`, but if destination repo have been created, the repo visibility will not be set, just only update the repo.

@@ -7,7 +7,7 @@

class Hub(object):
def __init__(
self, src, dst, dst_token, account_type="user",
self, src, dst, dst_token,dst_private, account_type="user",
Copy link
Owner

Choose a reason for hiding this comment

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

pep8 failed

@Yikun
Copy link
Owner

Yikun commented Apr 19, 2022

I added the comments according latest desigin.

@xiexianbin
Copy link

ping

@dislazy dislazy closed this May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants