mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 23:10:29 +03:00
import: get git commit ID from git repo, e.g. master instead of '?'
This commit is contained in:
parent
ddafcb9f8a
commit
32a29b3304
1 changed files with 10 additions and 8 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
|
import git
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
@ -241,32 +242,33 @@ def main():
|
||||||
app = metadata.App()
|
app = metadata.App()
|
||||||
app.AutoName = os.path.basename(os.getcwd())
|
app.AutoName = os.path.basename(os.getcwd())
|
||||||
app.RepoType = 'git'
|
app.RepoType = 'git'
|
||||||
app.UpdateCheckMode = "Tags"
|
|
||||||
|
|
||||||
if os.path.exists('build.gradle') or os.path.exists('build.gradle.kts'):
|
if os.path.exists('build.gradle') or os.path.exists('build.gradle.kts'):
|
||||||
build.gradle = ['yes']
|
build.gradle = ['yes']
|
||||||
|
|
||||||
import git
|
git_repo = git.repo.Repo(os.getcwd())
|
||||||
repo = git.repo.Repo(os.getcwd()) # git repo
|
for remote in git.Remote.iter_items(git_repo):
|
||||||
for remote in git.Remote.iter_items(repo):
|
|
||||||
if remote.name == 'origin':
|
if remote.name == 'origin':
|
||||||
url = repo.remotes.origin.url
|
url = git_repo.remotes.origin.url
|
||||||
if url.startswith('https://git'): # github, gitlab
|
if url.startswith('https://git'): # github, gitlab
|
||||||
app.SourceCode = url.rstrip('.git')
|
app.SourceCode = url.rstrip('.git')
|
||||||
app.Repo = url
|
app.Repo = url
|
||||||
break
|
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
|
write_local_file = True
|
||||||
elif options.url:
|
elif options.url:
|
||||||
app = get_app_from_url(options.url)
|
app = get_app_from_url(options.url)
|
||||||
build_dir = clone_to_tmp_dir(app)
|
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'
|
build.disable = 'Generated by import.py - check/set version fields and commit id'
|
||||||
write_local_file = False
|
write_local_file = False
|
||||||
else:
|
else:
|
||||||
raise FDroidException("Specify project url.")
|
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...
|
# Extract some information...
|
||||||
paths = get_all_gradle_and_manifests(build_dir)
|
paths = get_all_gradle_and_manifests(build_dir)
|
||||||
subdir = get_gradle_subdir(build_dir, paths)
|
subdir = get_gradle_subdir(build_dir, paths)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue