|
17 | 17 |
|
18 | 18 |
|
19 | 19 | class GitInspect(SubGit): |
20 | | - def __init__(self, config_file_name=None, answer_yes=None, is_archived=False): |
21 | | - self.answer_yes = answer_yes |
| 20 | + def __init__(self, is_archived=False): |
22 | 21 | self.is_archived = is_archived |
23 | | - self.config_file_name = config_file_name |
24 | | - |
25 | | - # Defaults config file to '.subgit-github.yml' if nothing is specified |
26 | | - if not config_file_name: |
27 | | - self.subgit_config_file_name = ".subgit.yml" |
28 | | - |
29 | | - if self.is_archived: |
30 | | - self.subgit_config_file_name = ".subgit-archived.yml" |
31 | | - else: |
32 | | - self.subgit_config_file_name = config_file_name |
33 | | - |
34 | | - self.subgit_config_file_path = os.path.join(os.getcwd(), self.subgit_config_file_name) |
35 | 22 |
|
36 | 23 | def _cli_installed(self, source): |
37 | 24 | """ |
@@ -110,37 +97,9 @@ def inspect_github(self, owner): |
110 | 97 | "url": repo_data["sshUrl"], |
111 | 98 | } |
112 | 99 |
|
113 | | - # If no config file name specfied, example file will be written to stdout |
114 | | - if not self.config_file_name: |
115 | | - log.info("Your '.subgit.yml' file would look like this:") |
116 | | - log.info("repos:") |
117 | | - |
118 | | - for repo in repos: |
119 | | - branch = repos[repo]["revision"]["branch"] |
120 | | - url = repos[repo]["url"] |
121 | | - log.info(f" {repo}:") |
122 | | - log.info(f" revision:") |
123 | | - log.info(f" branch: {branch}") |
124 | | - log.info(f" url: {url}") |
125 | | - |
126 | | - return 0 |
127 | | - |
128 | | - # If config file name specified, inspect command will look for the file and ask for |
129 | | - # confirmation whether user wants to overwrite this file |
130 | | - if os.path.exists(self.subgit_config_file_path): |
131 | | - answer = self.yes_no(f"File: {self.subgit_config_file_path} already exists on disk, do you want to overwrite the file?") |
132 | | - |
133 | | - if not answer: |
134 | | - log.error("Aborting writing to file...") |
135 | | - return 1 |
136 | | - |
137 | | - yml = yaml.YAML() |
138 | | - yml.indent(mapping=2, sequence=4, offset=2) |
139 | | - with open(self.subgit_config_file_path, "w") as stream: |
140 | | - yml.dump({"repos": repos}, stream) |
141 | | - |
142 | | - log.info(f"Successfully wrote to file: {self.subgit_config_file_name}") |
143 | | - return 0 |
| 100 | + yaml_output = yaml.dump({"repos": repos}, default_flow_style=False, indent=2) |
| 101 | + |
| 102 | + print(yaml_output) |
144 | 103 |
|
145 | 104 | def inspect_gitlab(self, owner): |
146 | 105 | """ |
@@ -191,34 +150,6 @@ def inspect_gitlab(self, owner): |
191 | 150 | "url": repo_data["ssh_url_to_repo"], |
192 | 151 | } |
193 | 152 |
|
194 | | - # If no config file name specfied, example file will be written to stdout |
195 | | - if not self.config_file_name: |
196 | | - log.info("Your '.subgit.yml' file would look like this:") |
197 | | - log.info("repos:") |
198 | | - |
199 | | - for repo in repos: |
200 | | - branch = repos[repo]["revision"]["branch"] |
201 | | - url = repos[repo]["url"] |
202 | | - log.info(f" {repo}:") |
203 | | - log.info(f" revision:") |
204 | | - log.info(f" branch: {branch}") |
205 | | - log.info(f" url: {url}") |
206 | | - |
207 | | - return 0 |
208 | | - |
209 | | - # If config file name specified, inspect command will look for the file and ask for |
210 | | - # confirmation whether user wants to overwrite this file |
211 | | - if os.path.exists(self.subgit_config_file_path): |
212 | | - answer = self.yes_no(f"File: {self.subgit_config_file_path} already exists on disk, do you want to overwrite the file?") |
213 | | - |
214 | | - if not answer: |
215 | | - log.error("Aborting writing to file...") |
216 | | - return 1 |
217 | | - |
218 | | - yml = yaml.YAML() |
219 | | - yml.indent(mapping=2, sequence=4, offset=2) |
220 | | - with open(self.subgit_config_file_path, "w") as stream: |
221 | | - yml.dump({"repos": repos}, stream) |
222 | | - |
223 | | - log.info(f"Successfully wrote to file: {self.subgit_config_file_name}") |
224 | | - return 0 |
| 153 | + yaml_output = yaml.dump({"repos": repos}, default_flow_style=False, indent=2) |
| 154 | + |
| 155 | + print(yaml_output) |
0 commit comments