1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-08-15 10:50:09 +02:00

import: get git commit ID from git repo, e.g. master instead of '?'

This commit is contained in:
Hans-Christoph Steiner 2020-02-17 17:05:46 +01:00
parent ddafcb9f8a
commit 32a29b3304
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import binascii
import git
import glob
import json
import os
@ -241,32 +242,33 @@ def main():
app = metadata.App()
app.AutoName = os.path.basename(os.getcwd())
app.RepoType = 'git'
app.UpdateCheckMode = "Tags"
if os.path.exists('build.gradle') or os.path.exists('build.gradle.kts'):
build.gradle = ['yes']
import git
repo = git.repo.Repo(os.getcwd()) # git repo
for remote in git.Remote.iter_items(repo):
git_repo = git.repo.Repo(os.getcwd())
for remote in git.Remote.iter_items(git_repo):
if remote.name == 'origin':
url = repo.remotes.origin.url
url = git_repo.remotes.origin.url
if url.startswith('https://git'): # github, gitlab
app.SourceCode = url.rstrip('.git')
app.Repo = url
break
# repo.head.commit.binsha is a bytearray stored in a str
build.commit = binascii.hexlify(bytearray(repo.head.commit.binsha))
write_local_file = True
elif options.url:
app = get_app_from_url(options.url)
build_dir = clone_to_tmp_dir(app)
build.commit = '?'
git_repo = git.repo.Repo(tmp_importer_dir)
build.disable = 'Generated by import.py - check/set version fields and commit id'
write_local_file = False
else:
raise FDroidException("Specify project url.")
app.UpdateCheckMode = 'Tags'
# repo.head.commit.binsha is a bytearray stored in a str
build.commit = binascii.hexlify(bytearray(git_repo.head.commit.binsha)).decode()
# Extract some information...
paths = get_all_gradle_and_manifests(build_dir)
subdir = get_gradle_subdir(build_dir, paths)