From 94b083063a1d116059720c1baccc0b0b39b438e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 6 Sep 2013 20:33:47 +0200 Subject: [PATCH 1/6] Add UCM:Tags support to hg --- docs/fdroid.texi | 5 +++-- fdroidserver/checkupdates.py | 4 ++-- fdroidserver/common.py | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/fdroid.texi b/docs/fdroid.texi index 924ecff9..4168c505 100644 --- a/docs/fdroid.texi +++ b/docs/fdroid.texi @@ -1077,8 +1077,9 @@ are known to forget to tag releases. Like RepoManifest, it will not return the correct value if the directory containing the AndroidManifest.xml has moved. Despite these caveats, it is the often the favourite update check mode. -It currently only works for git and git-svn repositories. In the case of the -latter, the repo URL must encode the path to the trunk and tags. +It currently only works for git, hg and git-svn repositories. In the case of +the latter, the repo URL must encode the path to the trunk and tags or else no +tags will be found. @end itemize @node Auto Update Mode diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index a1ba9586..9c39a2b3 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -50,8 +50,8 @@ def check_tags(app, sdk_path): build_dir = os.path.join('build/', app['id']) repotype = app['Repo Type'] - if repotype not in ('git', 'git-svn'): - return (None, 'Tags update mode only works for git and git-svn repositories currently') + if repotype not in ('git', 'git-svn', 'hg'): + return (None, 'Tags update mode only works for git, hg and git-svn repositories currently') # Set up vcs interface and make sure we have the latest code... vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index d418f790..51f9a955 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -342,6 +342,11 @@ class vcs_hg(vcs): cwd=self.local) != 0: raise VCSException("Hg checkout failed") + def gettags(self): + p = subprocess.Popen(['hg', 'tags', '-q'], + stdout=subprocess.PIPE, cwd=self.local) + return p.communicate()[0].splitlines()[1:] + class vcs_bzr(vcs): From fed04a0429d68d65f26804997804d1bf27b5b865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 6 Sep 2013 22:38:36 +0200 Subject: [PATCH 2/6] Don't print all metadata reads; Only print when an exception is present --- fdroidserver/common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 51f9a955..50319c3c 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -464,8 +464,6 @@ def parse_metadata(metafile, **kw): if not isinstance(metafile, file): metafile = open(metafile, "r") thisinfo['id'] = metafile.name[9:-4] - if kw.get("verbose", False): - print "Reading metadata for " + thisinfo['id'] else: thisinfo['id'] = None @@ -674,7 +672,11 @@ def write_metadata(dest, app): def read_metadata(verbose=False, xref=True): apps = [] for metafile in sorted(glob.glob(os.path.join('metadata', '*.txt'))): - apps.append(parse_metadata(metafile, verbose=verbose)) + try: + appinfo = parse_metadata(metafile, verbose=verbose) + except Exception, e: + raise MetaDataException("Problem reading metadata file %s: - %s" % (metafile, str(e))) + apps.append(appinfo) if xref: # Parse all descriptions at load time, just to ensure cross-referencing From e966634bc0fa5bffed1e3feeb7faa3f73949f4dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 6 Sep 2013 22:51:04 +0200 Subject: [PATCH 3/6] New aliased completion: fdroid checkupdates -p --- completion/bash-completion | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/completion/bash-completion b/completion/bash-completion index e254ec28..16bfc504 100644 --- a/completion/bash-completion +++ b/completion/bash-completion @@ -13,10 +13,15 @@ # alias fbuild='fdroid build' # complete -F _fdroid_build fbuild # -# There's also a completion function made for aliases to 'fdroid build -p': +# There are also completion function for '-p com.some.app' aliases: # -# alias fbld='fdroid build -p' +# alias fbld='fdroid build -v -l -p' # complete -F _fdroid_build_project fbld +# +# alias fcheckup='fdroid checkupdates -v -p' +# complete -F _fdroid_checkupdates_project fcheckup +# +# This way, one can simply do 'fbld com.some.app' or 'fcheckup com.some.app' __package() { [[ -d ./metadata ]] || return 0 @@ -197,6 +202,15 @@ _fdroid_build_project() { __complete_build } +_fdroid_checkupdates_project() { + local cur prev cmds opts lopts aliased + __fdroid_init + aliased=true + (( $COMP_CWORD == 1 )) && prev="-p" + + __complete_checkupdates +} + complete -F _fdroid fdroid return 0 From c87e6b0c160fd9489154a4a3a9b9e269cf1f19f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 6 Sep 2013 23:13:45 +0200 Subject: [PATCH 4/6] Do not search and replace metadata/ and .txt --- completion/bash-completion | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/completion/bash-completion b/completion/bash-completion index 16bfc504..537cbd3c 100644 --- a/completion/bash-completion +++ b/completion/bash-completion @@ -26,8 +26,8 @@ __package() { [[ -d ./metadata ]] || return 0 files=( metadata/*.txt ) - files=( ${files[@]/metadata\//} ) - files=${files[@]/.txt/} + files=( ${files[@]#metadata/} ) + files=${files[@]%.txt} COMPREPLY=( $( compgen -W "$files" -- $cur ) ) } From 4ffd3aefa55eb4da861fbabe044f8d0225592f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 6 Sep 2013 23:28:11 +0200 Subject: [PATCH 5/6] commitupdates now uses git commit -e (invokes editor) --- commitupdates | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commitupdates b/commitupdates index db05782c..69c24b38 100755 --- a/commitupdates +++ b/commitupdates @@ -25,9 +25,9 @@ while read line; do id=${id%.txt*} [ -d metadata/$id ] && extra=metadata/$id [ -n "$name" ] && id="$name ($id)" - - echo "> git commit -m \"Update $id to $version ($vercode)\" -- $file $extra" - git commit -m "Update $id to $version ($vercode)" -- $file $extra fi done < <(git status --porcelain) +echo "> git commit -m \"Update $id to $version ($vercode)\" -e -- $file $extra" +git commit -m "Update $id to $version ($vercode)" -e -- $file $extra + From c52203f87d9b045cf8ab5685a2b8324a428f7f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 6 Sep 2013 23:36:10 +0200 Subject: [PATCH 6/6] Save all commit updates in an array, loop over them later --- commitupdates | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/commitupdates b/commitupdates index 69c24b38..bde57e23 100755 --- a/commitupdates +++ b/commitupdates @@ -1,5 +1,7 @@ #!/bin/bash +commands=() + while read line; do if [[ "$line" == *M*metadata/*.txt ]]; then file=${line##* } @@ -25,9 +27,12 @@ while read line; do id=${id%.txt*} [ -d metadata/$id ] && extra=metadata/$id [ -n "$name" ] && id="$name ($id)" + + commands+=("git commit -m 'Update $id to $version ($vercode)' -e -- $file $extra") fi done < <(git status --porcelain) -echo "> git commit -m \"Update $id to $version ($vercode)\" -e -- $file $extra" -git commit -m "Update $id to $version ($vercode)" -e -- $file $extra +for cmd in "${commands[@]}"; do + eval "$cmd" +done