forked from importers/git-importer
		
	Compare commits
	
		
			5 Commits
		
	
	
		
			option_for
			...
			devel
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | c8455c22dc | ||
|  | 94fdb3b442 | ||
|  | f2358446da | ||
| 9660e633af | |||
| 85b9ed5e75 | 
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -9,5 +9,5 @@ test: | ||||
| update-packages: | ||||
| 	f=$$(mktemp) ;\ | ||||
| 	osc api /source/openSUSE:Factory?view=info | grep -v lsrcmd5 | grep srcmd5= | sed -e 's,.*package=",,; s,".*,,' | grep -v : > $$f ;\ | ||||
| 	echo _project >> $$f ;\ | ||||
| 	echo _project >> $$f;\ | ||||
| 	mv $$f packages | ||||
|   | ||||
							
								
								
									
										19
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,5 +1,18 @@ | ||||
| sudo zypper in python3-psycopg | ||||
| sudo su - postgres | ||||
| # `createdb -O <LOCAL_USER> imported_git` | ||||
| Installation | ||||
| ------------ | ||||
|  | ||||
|     sudo zypper in python3-psycopg | ||||
|     sudo su - postgres | ||||
|     createdb -O <LOCAL_USER> imported_git` | ||||
|  | ||||
| To reset the database, drop table scheme | ||||
|  | ||||
|  | ||||
| Gitea parameters | ||||
| ---------------- | ||||
|  | ||||
|   * `GITEA_HOST` - default: src.opensuse.org | ||||
|   * `GITEA_USER` - Used to generate SSH links for push. Default: gitea | ||||
|   * `GITEA_ORG`  - target organization to push to | ||||
|   * `GITEA_DEFAULT_BRANCH` - default branch | ||||
|  | ||||
|   | ||||
							
								
								
									
										18
									
								
								lib/git.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								lib/git.py
									
									
									
									
									
								
							| @@ -252,15 +252,27 @@ class Git: | ||||
|     def add_gitea_remote(self, package): | ||||
|         repo_name = package.replace("+", "_") | ||||
|         org_name = "rpm" | ||||
|         gitea_user = "gitea" | ||||
|         gitea_host = "src.opensuse.org" | ||||
|         default_branch = "factory" | ||||
|  | ||||
|         if os.getenv("GITEA_HOST"): | ||||
|             gitea_host = getenv("GITEA_HOST") | ||||
|         if os.getenv("GITEA_USER"): | ||||
|             gitea_user = getenv("GITEA_USER") | ||||
|         if os.getenv("GITEA_ORG"): | ||||
|             org_name = getenv("GITEA_ORG") | ||||
|         if os.getenv("GITEA_DEFAULT_BRANCH"): | ||||
|             default_branch = getenv("GITEA_DEFAULT_BRANCH") | ||||
|  | ||||
|         if not os.getenv("GITEA_TOKEN"): | ||||
|             logging.warning("Not adding a remote due to missing $GITEA_TOKEN") | ||||
|             return | ||||
|  | ||||
|         url = f"https://src.opensuse.org/api/v1/org/{org_name}/repos" | ||||
|         url = f"https://{gitea_host}/api/v1/org/{org_name}/repos" | ||||
|         response = requests.post( | ||||
|             url, | ||||
|             data={"name": repo_name, "object_format_name": "sha256"}, | ||||
|             data={"name": repo_name, "object_format_name": "sha256", "default_branch": default_branch}, | ||||
|             headers={"Authorization": f"token {os.getenv('GITEA_TOKEN')}"}, | ||||
|             timeout=10, | ||||
|         ) | ||||
| @@ -268,7 +280,7 @@ class Git: | ||||
|         # 201 Created | ||||
|         if response.status_code not in (201, 409): | ||||
|             print(response.data) | ||||
|         url = f"gitea@src.opensuse.org:{org_name}/{repo_name}.git" | ||||
|         url = f"{gitea_user}@{gitea_host}:{org_name}/{repo_name}.git" | ||||
|         self.git_run( | ||||
|             ["remote", "add", "origin", url], | ||||
|         ) | ||||
|   | ||||
| @@ -29,7 +29,7 @@ class GitExporter: | ||||
|             self.git.open() | ||||
|         else: | ||||
|             self.git.create() | ||||
|             self.git.add_gitea_remote(package) | ||||
|             # self.git.add_gitea_remote(package) | ||||
|         self.state_file = os.path.join(self.git.path, ".git", "_flat_state.yaml") | ||||
|         self.gc_interval = 200 | ||||
|         self.cachedir = cachedir | ||||
| @@ -47,7 +47,7 @@ class GitExporter: | ||||
|         left_to_commit = [] | ||||
|         for flat in reversed(flats): | ||||
|             found_state = False | ||||
|             for branch in ["factory"]: | ||||
|             for branch in ["factory", "devel"]: | ||||
|                 if flat.commit.dbid == state_data.get(branch): | ||||
|                     branch_state[branch] = flat.commit | ||||
|                     flat.commit.git_commit = self.git.branch_head(branch) | ||||
|   | ||||
| @@ -83,6 +83,7 @@ class LFSOid: | ||||
|             self.register() | ||||
|  | ||||
|     def check(self): | ||||
|         return True | ||||
|         url = f"http://localhost:9999/check/{self.sha256}/{self.size}" | ||||
|         response = requests.get( | ||||
|             url, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user