-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bulk refactoring so multigit can be also used as an imported module.
- Loading branch information
1 parent
2b1701e
commit 19a5939
Showing
8 changed files
with
89 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
This script is a Python implementation of `simplest-git-subrepos <https://github.com/jmnavarrol/simplest-git-subrepos>`_. | ||
|
||
:package: multigit |release| | ||
:author: `Jesús M. Navarro <mailto:[email protected]>`_ | ||
:license: `GNU General Public License v3.0 <https://github.com/jmnavarrol/python-multigit/blob/main/LICENSE>`_ | ||
:source: https://github.com/jmnavarrol/python-multigit | ||
""" | ||
|
||
__version__ = '0.11.6' | ||
|
||
# Import stuff | ||
import os, sys | ||
import argparse | ||
|
||
# "local" imports | ||
from .subrepos import Subrepos, SUBREPOS_FILE | ||
# Other imports so there's visibility of all classes in the module | ||
from .__main__ import __version__ | ||
from .gitrepo import Gitrepo | ||
from .subrepofile import Subrepofile | ||
|
||
|
||
|
||
# MAIN entry point | ||
def main(): | ||
'''Processes command line parameters''' | ||
parser = argparse.ArgumentParser( | ||
description="Manages git repos within git repos.", | ||
add_help=False, # this way I can force help to be an exclusion option along the others | ||
) | ||
|
||
# Main options | ||
main_parser = parser.add_mutually_exclusive_group() | ||
main_parser.add_argument('-h', '--help', action='store_true', help="Shows this help.") | ||
main_parser.add_argument('-V', '--version', action='store_true', help="Shows " + parser.prog + " version and quits.") | ||
main_parser.add_argument('-r', '--run', action='store_true', help="Recursively processes '" + SUBREPOS_FILE + "' files found.") | ||
main_parser.add_argument('-s', '--status', action='store_true', help="Shows repositories' current status.") | ||
|
||
# Ready to parse args | ||
args = parser.parse_args() | ||
#print(args) | ||
|
||
# Run on the options | ||
if len(sys.argv) > 1: | ||
if args.help: | ||
print("%s (%s)\n" % (parser.prog, __version__)) | ||
parser.print_help() | ||
elif args.version: | ||
print("%s %s" % (parser.prog, __version__)) | ||
else: | ||
my_subrepos = Subrepos() | ||
my_subrepos.process(os.getcwd(), report_only=args.status) | ||
else: | ||
# Program called with no arguments (shows help) | ||
print("%s (%s): arguments required.\n" % (parser.prog, __version__)) | ||
parser.print_help() | ||
|
||
|
||
if __name__ == '__main__': | ||
# execute only if run as a script | ||
sys.exit(main()) | ||
from .subrepos import Subrepos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import main | ||
""" | ||
**multigit** script is a Python implementation of `simplest-git-subrepos <https://github.com/jmnavarrol/simplest-git-subrepos>`_. | ||
:package: multigit |release| | ||
:author: `Jesús M. Navarro <mailto:[email protected]>`_ | ||
:license: `GNU General Public License v3.0 <https://github.com/jmnavarrol/python-multigit/blob/main/LICENSE>`_ | ||
:source: https://github.com/jmnavarrol/python-multigit | ||
""" | ||
|
||
__version__ = '0.11.7-dev1' | ||
|
||
# Import stuff | ||
import os, sys | ||
import argparse | ||
|
||
# "local" imports | ||
from .subrepos import Subrepos, SUBREPOS_FILE | ||
# Other imports so there's visibility of all classes in the module | ||
from .gitrepo import Gitrepo | ||
from .subrepofile import Subrepofile | ||
|
||
|
||
# MAIN entry point | ||
def main(): | ||
'''Processes command line parameters''' | ||
parser = argparse.ArgumentParser( | ||
description="Manages git repos within git repos.", | ||
add_help=False, # this way I can force help to be an exclusion option along the others | ||
) | ||
|
||
# Main options | ||
main_parser = parser.add_mutually_exclusive_group() | ||
main_parser.add_argument('-h', '--help', action='store_true', help="Shows this help.") | ||
main_parser.add_argument('-V', '--version', action='store_true', help="Shows " + parser.prog + " version and quits.") | ||
main_parser.add_argument('-r', '--run', action='store_true', help="Recursively processes '" + SUBREPOS_FILE + "' files found.") | ||
main_parser.add_argument('-s', '--status', action='store_true', help="Shows repositories' current status.") | ||
|
||
# Ready to parse args | ||
args = parser.parse_args() | ||
#print(args) | ||
|
||
# Run on the options | ||
if len(sys.argv) > 1: | ||
if args.help: | ||
print("%s (%s)\n" % (parser.prog, __version__)) | ||
parser.print_help() | ||
elif args.version: | ||
print("%s %s" % (parser.prog, __version__)) | ||
else: | ||
my_subrepos = Subrepos() | ||
my_subrepos.process(os.getcwd(), report_only=args.status) | ||
else: | ||
# Program called with no arguments (shows help) | ||
print("%s (%s): arguments required.\n" % (parser.prog, __version__)) | ||
parser.print_help() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
|
||
sys.exit( | ||
main() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters