Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 11: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 11 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith Gerrit-Comment-Date: Thu, 08 Nov 2018 14:03:44 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Neels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 397 insertions(+), 298 deletions(-) Approvals: osmith: Looks good to me, but someone else must approve; Verified Neels Hofmeyr: Looks good to me, approved diff --git a/src/README b/src/README index a2fbe81..f066561 100644 --- a/src/README +++ b/src/README @@ -11,12 +11,11 @@ Pass a patch number seen on gerrit to fetch the latest patch set into your git clone. See top comment in the script. - ./g run a git command in each source tree - ./e run an arbitrary shell command in each source tree - ./st show a brief branch and local mods status for each source tree - ./s walk through each source tree and use gitk as well as user interaction - to quickly fast-forward / reset changes coming in from upstream. (This - is potentially dangerous, but safe if you only hit enter every time.) + gits Conveniently manage several git clones: +- run a git or shell command in each source tree + - show a brief branch and local mods status for each source tree + - merge / rebase / fast-forward each source tree interactively + See ./gits help Examples: @@ -54,7 +53,7 @@ - -./g fetch# run 'git fetch' in each clone = fetch all from upstream +./gits fetch# run 'git fetch' in each clone = fetch all from upstream = libasn1c = remote: Counting objects: 29, done @@ -90,7 +89,7 @@ - -./st # any modifications / updates? (e.g. useful after './g fetch') +./gits st# any modifications / updates? (e.g. useful after './g fetch') # (checks only 'master' and the current checked-out branch) libasn1c master @@ -116,13 +115,13 @@ - -./e rm .version # in each source tree, remove the local .version file +./gits sh rm .version # in each source tree, remove the local .version file - -./s # interactively try to fast-forward to upstream and/or save -# local modifications. -# If you just hit Enter all the time, nothing will be changed. +./gits rebase # interactively try to fast-forward to upstream and/or save + # local modifications. + # If you just hit Enter all the time, nothing dangerous will happen. libosmocore diff --git a/src/e b/src/e deleted file mode 100755 index 4d32bf1..000 --- a/src/e +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python3 -import os -import os.path -import sys -import subprocess - -base_dir = os.getcwd() - -for p in list(os.listdir('.')): - subdir = os.path.join(base_dir, p) - if not os.path.isdir(os.path.join(subdir, '.git')): - continue - print("\n= %s =" % p) - os.chdir(subdir) - subprocess.call(sys.argv[1:]) diff --git a/src/g b/src/g deleted file mode 100755 index bb9b693..000 --- a/src/g +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -import subprocess - -git_subdirs = [] - -for subdir in os.listdir(): - if not os.path.isdir(os.path.join(subdir, '.git')): -continue - - print('\n= %s =' % subdir) - sys.stdout.flush() - subprocess.call(['git', '-C', subdir] + sys.argv[1:]) - sys.stdout.flush() - sys.stderr.flush() diff --git a/src/git_branch_summary.py b/src/git_branch_summary.py deleted file mode 100755 index 9d81f8b..000 --- a/src/git_branch_summary.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python - -import sys, subprocess, re - -if len(sys.argv) < 2: - print("Usage: %s [...]\nThis is mostly here for helping the 'st' script." % sys.argv[0]) - exit(1) - -interesting_branch_names = [ 'master', 'sysmocom/iu', 'sysmocom/sccp', 'aper-prefix-onto-upstream' ] - -re_branch_name = re.compile('^..([^ ]+) .*') -re_ahead = re.compile('ahead [0-9]+|behind [0-9]+') - -def branch_name(line): - m = re_branch_name.match(line) - return m.group(1) - -interesting = [] - -def do_one_git(git_dir): - global interesting - branch_strs = subprocess.check_output(('git', '-C', git_dir, 'branch', '-vv')).decode('utf-8').splitlines() - interesting_branches = [] - - for
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
osmith has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 11: Verified+1 Code-Review+1 > my --porcelain --long seems to be identical to just status: I was wondering if --porcelain --long changed the output to "up-to-date" (with dashes) in your git version as well. But it seemed not to be the case because you did not modify the string to compare against. So I've added the version with dashes too, otherwise "gits status" is broken for me (patchset 9) and removed "--procelain" because it's irritating when it has no effect (patchset 11). > That said, if you want to change it to argparse so that it works and looks > good, do go ahead in a follow-up patch. ok? Done in patchset 10. I think it also looks good with argparse now, what do you think? $ ./gits -h usage: gits [-h] {status,st,s,fetch,f,rebase,r,re,sh,do} ... gits: conveniently manage several git subdirectories. Instead of doing the 'cd foo; git status; cd ../bar; git status' dance, this helps to save your time with: status, fetch, rebase, ... optional arguments: -h, --helpshow this help message and exit action: {status,st,s,fetch,f,rebase,r,re,sh,do} status (st, s) show a branch summary and indicate modifications fetch (f) run 'git fetch' in each clone (use before rebase) rebase (r, re) interactively ff-merge master, rebase current branches sh run shell command in each clone (`gits sh echo hi`) do run git command in each clone (`gits do clean -dxf`) -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 11 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith Gerrit-Comment-Date: Thu, 08 Nov 2018 10:46:59 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
osmith has uploaded a new patch set (#11) to the change originally created by Neels Hofmeyr. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 397 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/11 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 11 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
osmith has uploaded a new patch set (#10) to the change originally created by Neels Hofmeyr. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 397 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/10 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 10 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
osmith has uploaded a new patch set (#9) to the change originally created by Neels Hofmeyr. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 434 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/9 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 9 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 7: Are we through with this now? -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 7 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith Gerrit-Comment-Date: Wed, 07 Nov 2018 16:26:25 + Gerrit-HasComments: No Gerrit-HasLabels: No
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 7: (3 comments) https://gerrit.osmocom.org/#/c/11560/4/src/gits File src/gits: https://gerrit.osmocom.org/#/c/11560/4/src/gits@68 PS4, Line 68: l: > This seems to work - do you get the same output with your version? […] my --porcelain --long seems to be identical to just status: ▶ git status --porcelain --long On branch neels/wip Your branch and 'origin/neels/wip' have diverged, and have 9 and 6 different commits each, respectively. (use "git pull" to merge the remote branch into yours) Untracked files: (use "git add ..." to include in what will be committed) ../d.bsc/ ../m2/ ../make/ ../net/config_mine ../net/config_sip ../net/my_network/ ../net/nitb/ ../net/simcards.csv ../net/sip/ ../net/tmpl_dyn/ ../openbsc/ ../quick_vty_tests.opts nothing added to commit but untracked files present (use "git add" to track) https://gerrit.osmocom.org/#/c/11560/4/src/gits@359 PS4, Line 359: def cmd_fetch(): > you don't need a shim for every git command, you can just put them in a list > and iterate over them: […] Re: shim: the best for consistent help doc is to just add a shim. Re argparse: I see .. seems to me an awful lot of trouble for just sys.argv[1:]. BTW, one thing I don't like about argparse is that it removes line feeds, i.e. paragraphs, from the doc string. In osmo_interact I did parser = argparse.ArgumentParser(description=doc, formatter_class=argparse.RawDescriptionHelpFormatter) but then you also need to take care of line feeds for option arg docs. All in all it often is more meh than yay to me. That said, if you want to change it to argparse so that it works and looks good, do go ahead in a follow-up patch. ok? https://gerrit.osmocom.org/#/c/11560/5/src/gits File src/gits: https://gerrit.osmocom.org/#/c/11560/5/src/gits@6 PS5, Line 6: # This program is free software: you can redistribute it and/or modify > Out of curiosity: why not use the shorter SPDX form? […] because I just copy-paste these things from elsewhere :P -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 7 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith Gerrit-Comment-Date: Wed, 07 Nov 2018 16:25:53 + Gerrit-HasComments: Yes Gerrit-HasLabels: No
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Hello osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/11560 to look at the new patch set (#8). Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 432 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/8 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 8 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Hello osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/11560 to look at the new patch set (#7). Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 432 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/7 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 7 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
osmith has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 5: Code-Review-1 (6 comments) gits was not executable in the last patchset (chmod +x gits) https://gerrit.osmocom.org/#/c/11560/4/src/gits File src/gits: https://gerrit.osmocom.org/#/c/11560/4/src/gits@2 PS4, Line 2: > the reason why argparse will not work so well is passing arguments to git. > consider: […] this works well with argparse, see the example below https://gerrit.osmocom.org/#/c/11560/4/src/gits@68 PS4, Line 68: args): > yeah, that's the main ultra drawback of this script so far. I really really > shouldn't use porcelain. […] This seems to work - do you get the same output with your version? $ git status --porcelain --long On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working tree clean https://gerrit.osmocom.org/#/c/11560/4/src/gits@194 PS4, Line 194: lines = [] > I like more visible markers in this case What I meant: keep the marker that is there, and add this line below: print('+ %s' % ' '.join(cmd)) https://gerrit.osmocom.org/#/c/11560/4/src/gits@359 PS4, Line 359: for git_dir in git_dirs(): > but I want to write 'gits fetch' :) […] you don't need a shim for every git command, you can just put them in a list and iterate over them: import argparse def parse_args(): parser = argparse.ArgumentParser() sub = parser.add_subparsers(title="action", dest="action") sub.required = True sub.add_parser("status", aliases=["s", "st"], help="show a branch summary...") do = sub.add_parser("do", help="run arbitrary git command...") do.add_argument("args_passed", nargs=argparse.REMAINDER) # direct pass-through to git for action in ["fetch"]: action_parser = sub.add_parser(action) action_parser.add_argument("args_passed", nargs=argparse.REMAINDER) return parser.parse_args() if __name__ == '__main__': args = parse_args() if args.action == "status": cmd_status() # ... (other commands here) elif args.action == "do": cmd_do(args.args_passed) else: # pass directly through to git cmd_do([args.action] + args.args_passed) https://gerrit.osmocom.org/#/c/11560/4/src/gits@362 PS4, Line 362: sys.stdout.flush() > wow, you're just as obsessed with details like I am! yeah :) https://gerrit.osmocom.org/#/c/11560/5/src/gits File src/gits: https://gerrit.osmocom.org/#/c/11560/5/src/gits@6 PS5, Line 6: # This program is free software: you can redistribute it and/or modify Out of curiosity: why not use the shorter SPDX form? # SPDX-License-Identifier: GPL-3.0-or-later -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 5 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith Gerrit-Comment-Date: Wed, 07 Nov 2018 10:47:47 + Gerrit-HasComments: Yes Gerrit-HasLabels: Yes
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Hello osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/11560 to look at the new patch set (#5). Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 426 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/5 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 5 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 4: (13 comments) patch set coming up... https://gerrit.osmocom.org/#/c/11560/4/src/gits File src/gits: https://gerrit.osmocom.org/#/c/11560/4/src/gits@2 PS4, Line 2: argparse > argparse is not used. […] the reason why argparse will not work so well is passing arguments to git. consider: gits clean -dxf then 'gits' will argparse the -dxf arguments, but they were intended to be passed on to each 'cd subdir/; git clean -dxf' cmdline. good catch about -h https://gerrit.osmocom.org/#/c/11560/4/src/gits@11 PS4, Line 11: re_status_mods = re.compile('^\t(modified|deleted):.*') > This is only used once in the code. […] I think I'd rather precompile all others here as well https://gerrit.osmocom.org/#/c/11560/4/src/gits@29 PS4, Line 29: print(' '.join(cmd)) > How about differentiating the command from the output it produces? For > example with a leading '>' ch […] can do. I think I'd use the '+ ' ala 'set -x' https://gerrit.osmocom.org/#/c/11560/4/src/gits@37 PS4, Line 37: sys.stderr.flush() > why flush the output only when the section_marker is needed? not sure. probably came from previous code... should probably flush above instead https://gerrit.osmocom.org/#/c/11560/4/src/gits@45 PS4, Line 45: m > how about "branch" as variable name? it's a re "match object" https://gerrit.osmocom.org/#/c/11560/4/src/gits@48 PS4, Line 48: return m.group(1) this one is the branch https://gerrit.osmocom.org/#/c/11560/4/src/gits@68 PS4, Line 68: up to date > With git 2.11.0 I get: […] yeah, that's the main ultra drawback of this script so far. I really really shouldn't use porcelain. I'm not sure how to use plumbing though, so far it's "works-for-me" -- do you know how to fix that? https://gerrit.osmocom.org/#/c/11560/4/src/gits@122 PS4, Line 122: strs.append(''.join(branch_info)) > why make a list first, and then join it? that's my common string composition pattern. If I do "str = str + more", then I create an ever growing string in a loop. If I append to a list and later join, I only create one large string in the end. Well, it's premature optimization, but I prefer that style. In this instance it was about conditionally adding strings. a bit overboard, yes https://gerrit.osmocom.org/#/c/11560/4/src/gits@194 PS4, Line 194: print('\n= %s =' % git_dir) > If we print out something like "> cd %s && %s" before the output of the > command, it would be consist […] I like more visible markers in this case https://gerrit.osmocom.org/#/c/11560/4/src/gits@200 PS4, Line 200: SkipThisRepos > How about "SkipThisRepo"? repo is commonly used to abbreviate repository, so > when reading "repos" I' […] I've always thought of "repos", not "repo", had the same "conflict" with stsp many years ago... :) https://gerrit.osmocom.org/#/c/11560/4/src/gits@223 PS4, Line 223: if v == answer: : return answer : if v == '*': : return answer > how about: […] I see, but I prefer listing each valid_answers case in its separate 'if' https://gerrit.osmocom.org/#/c/11560/4/src/gits@359 PS4, Line 359: cmd_do(sys.argv[1:]) > I'm not sure if it's a good idea to perform "do" by default - whenever > there's a typo in any of the […] but I want to write 'gits fetch' :) and don't want to write a shim for each and every one of those... you're right of course, maybe a shim then. https://gerrit.osmocom.org/#/c/11560/4/src/gits@362 PS4, Line 362: # vim: shiftwidth=2 expandtab tabstop=2 > Since there are not Python coding guidelines in the wiki yet: […] wow, you're just as obsessed with details like I am! -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith Gerrit-Comment-Date: Tue, 06 Nov 2018 15:31:09 + Gerrit-HasComments: Yes Gerrit-HasLabels: No
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
osmith has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 4: Code-Review-1 (19 comments) https://gerrit.osmocom.org/#/c/11560/4/src/gits File src/gits: https://gerrit.osmocom.org/#/c/11560/4/src/gits@1 PS4, Line 1: #!/usr/bin/env python3 Add the copyright and SPDX license lines here? https://gerrit.osmocom.org/#/c/11560/4/src/gits@2 PS4, Line 2: argparse argparse is not used. But I would highly recommend to use it: * the help output would look like in any other python program * right now "./gits -h" runs "git -h" in every directory instead of printing the help output * no wheel-reinventing for checking the arguments, cmd_help(), having aliases https://gerrit.osmocom.org/#/c/11560/4/src/gits@11 PS4, Line 11: re_status_mods = re.compile('^\t(modified|deleted):.*') This is only used once in the code. There are other regex patterns, that are not global variables in this file. So I'd recommend to follow that pattern and move this to the function where it is needed. https://gerrit.osmocom.org/#/c/11560/4/src/gits@29 PS4, Line 29: print(' '.join(cmd)) How about differentiating the command from the output it produces? For example with a leading '>' character: > git -C osmo-mgw status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working dir clean https://gerrit.osmocom.org/#/c/11560/4/src/gits@37 PS4, Line 37: sys.stderr.flush() why flush the output only when the section_marker is needed? https://gerrit.osmocom.org/#/c/11560/4/src/gits@45 PS4, Line 45: m how about "branch" as variable name? https://gerrit.osmocom.org/#/c/11560/4/src/gits@68 PS4, Line 68: up to date With git 2.11.0 I get: unknown status str: "Your branch is up-to-date with 'origin/master'." (There's "git status --porcelain" which is meant to be parsed, but it doesn't print the branch line - maybe there's an appropriate git plumbing command with stable output that can be used instead?) https://gerrit.osmocom.org/#/c/11560/4/src/gits@79 PS4, Line 79: m How about "status"? https://gerrit.osmocom.org/#/c/11560/4/src/gits@87 PS4, Line 87: here are two empty lines after the function, mostly this file has one empty line instead. PEP8 would be using two empty lines between each function. https://gerrit.osmocom.org/#/c/11560/4/src/gits@89 PS4, Line 89: '''return a list of strings: [branchname, info0, info1,...]''' it's not clear what info0, info1 etc. would be. Maybe add examples with actual strings? https://gerrit.osmocom.org/#/c/11560/4/src/gits@91 PS4, Line 91: interesting_branch_names = [ 'master' ] : : strs = [git_dir,] (inconsistent: [ text ] vs [text,]) How about renaming "strs" to "ret" to indicate that this will be returned? https://gerrit.osmocom.org/#/c/11560/4/src/gits@122 PS4, Line 122: strs.append(''.join(branch_info)) why make a list first, and then join it? https://gerrit.osmocom.org/#/c/11560/4/src/gits@194 PS4, Line 194: print('\n= %s =' % git_dir) If we print out something like "> cd %s && %s" before the output of the command, it would be consistent with executing git in every folder. https://gerrit.osmocom.org/#/c/11560/4/src/gits@200 PS4, Line 200: SkipThisRepos How about "SkipThisRepo"? repo is commonly used to abbreviate repository, so when reading "repos" I'm thinking this is a plural form. https://gerrit.osmocom.org/#/c/11560/4/src/gits@207 PS4, Line 207: repos "repo"? https://gerrit.osmocom.org/#/c/11560/4/src/gits@223 PS4, Line 223: if v == answer: : return answer : if v == '*': : return answer how about: if v in (answer, "*"): return answer (somehow gerrit puts this comment in a single line without writing something below the code block) https://gerrit.osmocom.org/#/c/11560/4/src/gits@227 PS4, Line 227: if v == '+' and len(answer) > 0: (the > 0 is not needed) https://gerrit.osmocom.org/#/c/11560/4/src/gits@359 PS4, Line 359: cmd_do(sys.argv[1:]) I'm not sure if it's a good idea to perform "do" by default - whenever there's a typo in any of the actions, it will be executed in every directory. https://gerrit.osmocom.org/#/c/11560/4/src/gits@362 PS4, Line 362: # vim: shiftwidth=2 expandtab tabstop=2 Since there are not Python coding guidelines in the wiki yet: https://osmocom.org/projects/cellular-infrastructure/wiki/Coding_standards How about following PEP8 (Style Guide for Python Code) instead? https://www.python.org/dev/peps/pep-0008/ "Use 4 spaces per indentation level." There are nice tools like "flake8" which automatically check the formatting, and also auto formatting tools like "autopep8". -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osm
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 4: osmith, if you're reading this -- I'm counting on your review -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith Gerrit-Comment-Date: Mon, 05 Nov 2018 04:09:23 + Gerrit-HasComments: No Gerrit-HasLabels: No
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Hello osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/11560 to look at the new patch set (#4). Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 373 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/4 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 4 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Hello osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/11560 to look at the new patch set (#3). Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 369 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/3 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 3 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Hello osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/11560 to look at the new patch set (#2). Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 354 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/2 -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 2 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: osmith
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11560 ) Change subject: replace src/* git scripts with a single src/gits .. Patch Set 1: I'm not sure that this is ready yet, will work with it for a few days to see if it still needs fixing. But uploading it already to share with osmith. -- To view, visit https://gerrit.osmocom.org/11560 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-dev Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 Gerrit-Change-Number: 11560 Gerrit-PatchSet: 1 Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-Comment-Date: Wed, 31 Oct 2018 20:41:10 + Gerrit-HasComments: No Gerrit-HasLabels: No
Change in osmo-dev[master]: replace src/* git scripts with a single src/gits
Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/11560 Change subject: replace src/* git scripts with a single src/gits .. replace src/* git scripts with a single src/gits I keep re-using this functionality in completely unrelated realms, and decided to unify the oddly named scripts in a single 'gits' meta-repos tool, so I can just symlink this script into my ~/bin and use it everywhere. Change-Id: I579e7af26d76d5c5d83b2349695456bc7b54f5a2 --- M src/README D src/e D src/g D src/git_branch_summary.py A src/gits D src/s D src/st 7 files changed, 353 insertions(+), 298 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/60/11560/1 diff --git a/src/README b/src/README index a2fbe81..f066561 100644 --- a/src/README +++ b/src/README @@ -11,12 +11,11 @@ Pass a patch number seen on gerrit to fetch the latest patch set into your git clone. See top comment in the script. - ./g run a git command in each source tree - ./e run an arbitrary shell command in each source tree - ./st show a brief branch and local mods status for each source tree - ./s walk through each source tree and use gitk as well as user interaction - to quickly fast-forward / reset changes coming in from upstream. (This - is potentially dangerous, but safe if you only hit enter every time.) + gits Conveniently manage several git clones: +- run a git or shell command in each source tree + - show a brief branch and local mods status for each source tree + - merge / rebase / fast-forward each source tree interactively + See ./gits help Examples: @@ -54,7 +53,7 @@ - -./g fetch# run 'git fetch' in each clone = fetch all from upstream +./gits fetch# run 'git fetch' in each clone = fetch all from upstream = libasn1c = remote: Counting objects: 29, done @@ -90,7 +89,7 @@ - -./st # any modifications / updates? (e.g. useful after './g fetch') +./gits st# any modifications / updates? (e.g. useful after './g fetch') # (checks only 'master' and the current checked-out branch) libasn1c master @@ -116,13 +115,13 @@ - -./e rm .version # in each source tree, remove the local .version file +./gits sh rm .version # in each source tree, remove the local .version file - -./s # interactively try to fast-forward to upstream and/or save -# local modifications. -# If you just hit Enter all the time, nothing will be changed. +./gits rebase # interactively try to fast-forward to upstream and/or save + # local modifications. + # If you just hit Enter all the time, nothing dangerous will happen. libosmocore diff --git a/src/e b/src/e deleted file mode 100755 index 4d32bf1..000 --- a/src/e +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python3 -import os -import os.path -import sys -import subprocess - -base_dir = os.getcwd() - -for p in list(os.listdir('.')): - subdir = os.path.join(base_dir, p) - if not os.path.isdir(os.path.join(subdir, '.git')): - continue - print("\n= %s =" % p) - os.chdir(subdir) - subprocess.call(sys.argv[1:]) diff --git a/src/g b/src/g deleted file mode 100755 index bb9b693..000 --- a/src/g +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -import subprocess - -git_subdirs = [] - -for subdir in os.listdir(): - if not os.path.isdir(os.path.join(subdir, '.git')): -continue - - print('\n= %s =' % subdir) - sys.stdout.flush() - subprocess.call(['git', '-C', subdir] + sys.argv[1:]) - sys.stdout.flush() - sys.stderr.flush() diff --git a/src/git_branch_summary.py b/src/git_branch_summary.py deleted file mode 100755 index 9d81f8b..000 --- a/src/git_branch_summary.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python - -import sys, subprocess, re - -if len(sys.argv) < 2: - print("Usage: %s [...]\nThis is mostly here for helping the 'st' script." % sys.argv[0]) - exit(1) - -interesting_branch_names = [ 'master', 'sysmocom/iu', 'sysmocom/sccp', 'aper-prefix-onto-upstream' ] - -re_branch_name = re.compile('^..([^ ]+) .*') -re_ahead = re.compile('ahead [0-9]+|behind [0-9]+') - -def branch_name(line): - m = re_branch_name.match(line) - return m.group(1) - -interesting = [] - -def do_one_git(git_dir): - global interesting - branch_strs = subprocess.check_output(('git', '-C', git_dir, 'branch', '-vv')).decode('utf-8').splitlines() - interesting_branches = [] - - for line in branch_strs: -name = branch_name(line) -