Lines Matching +full:ls +full:- +full:remote
7 # http://www.apache.org/licenses/LICENSE-2.0
27 def fetch(proj_path: Path, remote_name: str, branch: str | None = None) -> None:
32 remote_name: A string to specify remote names.
34 cmd = ['git', 'fetch', '--tags', remote_name] + ([branch] if branch is not None else [])
38 def add_remote(proj_path: Path, name: str, url: str) -> None:
39 """Adds a git remote.
43 name: Name of the new remote.
44 url: Url of the new remote.
46 cmd = ['git', 'remote', 'add', name, url]
50 def remove_remote(proj_path: Path, name: str) -> None:
51 """Removes a git remote."""
52 cmd = ['git', 'remote', 'remove', name]
56 def list_remotes(proj_path: Path) -> dict[str, str]:
63 A dict from remote name to remote url.
65 def parse_remote(line: str) -> tuple[str, str]:
69 cmd = ['git', 'remote', '-v']
76 def detect_default_branch(proj_path: Path, remote_name: str) -> str:
78 cmd = ['git', 'remote', 'show', remote_name]
84 return line.split()[-1]
86 f"Could not find HEAD branch in 'git remote show {remote_name}'"
92 cmd = ['git', 'rev-parse', branch]
97 def get_most_recent_tag(proj_path: Path, branch: str) -> str | None:
99 cmd = ['git', 'describe', '--tags', branch, '--abbrev=0'] + \
100 [f'--exclude={unwanted_tag}' for unwanted_tag in UNWANTED_TAGS]
113 # pylint: disable=redefined-outer-name
114 def get_commit_time(proj_path: Path, commit: str) -> datetime.datetime:
116 cmd = ['git', 'show', '-s', '--format=%ct', commit]
122 def list_remote_branches(proj_path: Path, remote_name: str) -> list[str]:
123 """Lists all branches for a remote."""
124 cmd = ['git', 'branch', '-r']
135 def list_local_branches(proj_path: Path) -> list[str]:
137 cmd = ['git', 'branch', '--format=%(refname:short)']
143 COMMIT_PATTERN = r'^[a-f0-9]{40}$'
147 # pylint: disable=redefined-outer-name
148 def is_commit(commit: str) -> bool:
153 def merge(proj_path: Path, branch: str) -> None:
156 cmd = ['git', 'merge', branch, '--no-commit']
165 def merge_conflict(proj_path: Path) -> bool:
167 cmd = ['git', 'ls-files', '--unmerged']
173 def add_file(proj_path: Path, file_name: str) -> None:
179 def remove_gitmodules(proj_path: Path) -> None:
181 cmd = ['find', '.', '-name', '.gitmodules', '-delete']
185 def delete_branch(proj_path: Path, branch_name: str) -> None:
187 cmd = ['git', 'branch', '-D', branch_name]
191 def start_branch(proj_path: Path, branch_name: str) -> None:
196 def commit(proj_path: Path, message: str, no_verify: bool) -> None:
198 cmd = ['git', 'commit', '-m', message] + (['--no-verify'] if no_verify is True else [])
202 def commit_amend(proj_path: Path) -> None:
204 cmd = ['git', 'commit', '--amend', '--no-edit']
208 def checkout(proj_path: Path, branch_name: str) -> None:
214 def detach_to_android_head(proj_path: Path) -> None:
216 # -d detaches the project back to the manifest revision without updating.
217 # -l avoids fetching new revisions from the remote. This might be superfluous with
218 # -d, but I'm not sure, and it certainly doesn't harm anything.
219 subprocess.run(['repo', 'sync', '-l', '-d', proj_path], cwd=proj_path, check=True)
222 def push(proj_path: Path, remote_name: str, has_errors: bool) -> None:
223 """Pushes change to remote."""
224 cmd = ['git', 'push', remote_name, 'HEAD:refs/for/main', '-o', 'banned-words~skip']
226 cmd.extend(['-o', revs])
228 cmd.extend(['-o', 't=' + tag])
230 cmd.extend(['-o', 'l=Verified-1'])
234 def reset_hard(proj_path: Path) -> None:
236 cmd = ['git', 'reset', '--hard']
240 def clean(proj_path: Path) -> None:
242 cmd = ['git', 'clean', '-fdx']
246 def is_valid_url(proj_path: Path, url: str) -> bool:
247 cmd = ['git', "ls-remote", url]
253 def list_remote_tags(proj_path: Path, remote_name: str) -> list[str]:
254 """Lists tags in a remote repository."""
255 cmd = ['git', "ls-remote", "--tags", remote_name]
262 def diff(proj_path: Path, diff_filter: str, revision: str) -> str:
264 cmd = ['git', 'diff', revision, '--stat', f'--diff-filter={diff_filter}']
272 def is_ancestor(proj_path: Path, ancestor: str, child: str) -> bool:
273 cmd = ['git', 'merge-base', '--is-ancestor', ancestor, child]
274 # https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---is-ancestor
296 def list_branches_with_commit(proj_path: Path, commit: str, remote_name: str) -> list[str]:
298 cmd = ['git', 'branch', '-r', '--contains', commit]