diff options
Diffstat (limited to 'scripts/oe-git-archive')
-rwxr-xr-x | scripts/oe-git-archive | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/oe-git-archive b/scripts/oe-git-archive index 419332ded1..117118b04e 100755 --- a/scripts/oe-git-archive +++ b/scripts/oe-git-archive | |||
@@ -55,7 +55,7 @@ def format_str(string, fields): | |||
55 | string, err, ', '.join(sorted(fields.keys())))) | 55 | string, err, ', '.join(sorted(fields.keys())))) |
56 | 56 | ||
57 | 57 | ||
58 | def init_git_repo(path, no_create): | 58 | def init_git_repo(path, no_create, bare): |
59 | """Initialize local Git repository""" | 59 | """Initialize local Git repository""" |
60 | path = os.path.abspath(path) | 60 | path = os.path.abspath(path) |
61 | if os.path.isfile(path): | 61 | if os.path.isfile(path): |
@@ -72,7 +72,7 @@ def init_git_repo(path, no_create): | |||
72 | raise ArchiveError("Failed to mkdir {}: {}".format(path, err)) | 72 | raise ArchiveError("Failed to mkdir {}: {}".format(path, err)) |
73 | if not os.listdir(path): | 73 | if not os.listdir(path): |
74 | log.info("Initializing a new Git repo at %s", path) | 74 | log.info("Initializing a new Git repo at %s", path) |
75 | repo = GitRepo.init(path) | 75 | repo = GitRepo.init(path, bare) |
76 | try: | 76 | try: |
77 | repo = GitRepo(path, is_topdir=True) | 77 | repo = GitRepo(path, is_topdir=True) |
78 | except GitError: | 78 | except GitError: |
@@ -108,7 +108,7 @@ def git_commit_data(repo, data_dir, branch, message): | |||
108 | repo.run_cmd(git_cmd) | 108 | repo.run_cmd(git_cmd) |
109 | 109 | ||
110 | # Update current HEAD, if we're on branch 'branch' | 110 | # Update current HEAD, if we're on branch 'branch' |
111 | if repo.get_current_branch() == branch: | 111 | if not repo.bare and repo.get_current_branch() == branch: |
112 | log.info("Updating %s HEAD to latest commit", repo.top_dir) | 112 | log.info("Updating %s HEAD to latest commit", repo.top_dir) |
113 | repo.run_cmd('reset --hard') | 113 | repo.run_cmd('reset --hard') |
114 | 114 | ||
@@ -158,6 +158,9 @@ def parse_args(argv): | |||
158 | parser.add_argument('--no-create', action='store_true', | 158 | parser.add_argument('--no-create', action='store_true', |
159 | help="If GIT_DIR is not a valid Git repository, do not " | 159 | help="If GIT_DIR is not a valid Git repository, do not " |
160 | "try to create one") | 160 | "try to create one") |
161 | parser.add_argument('--bare', action='store_true', | ||
162 | help="Initialize a bare repository when creating a " | ||
163 | "new one") | ||
161 | parser.add_argument('--push', '-p', nargs='?', default=False, const=True, | 164 | parser.add_argument('--push', '-p', nargs='?', default=False, const=True, |
162 | help="Push to remote") | 165 | help="Push to remote") |
163 | parser.add_argument('--branch-name', '-b', | 166 | parser.add_argument('--branch-name', '-b', |
@@ -195,7 +198,7 @@ def main(argv=None): | |||
195 | if not os.path.isdir(args.data_dir): | 198 | if not os.path.isdir(args.data_dir): |
196 | raise ArchiveError("Not a directory: {}".format(args.data_dir)) | 199 | raise ArchiveError("Not a directory: {}".format(args.data_dir)) |
197 | 200 | ||
198 | data_repo = init_git_repo(args.git_dir, args.no_create) | 201 | data_repo = init_git_repo(args.git_dir, args.no_create, args.bare) |
199 | 202 | ||
200 | # Get keywords to be used in tag and branch names and messages | 203 | # Get keywords to be used in tag and branch names and messages |
201 | metadata = metadata_from_bb() | 204 | metadata = metadata_from_bb() |