mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +08:00
Stop guessing the default branch
Talk to the remote via ssh and ask it which is the default branch. This has only been implemented for Android right now, so this breaks the ios build. Fixes #363
This commit is contained in:
@ -241,6 +241,20 @@ class GitNoteRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> defaultBranch(String remoteName) async {
|
||||||
|
try {
|
||||||
|
return await _gitRepo.defaultBranch(
|
||||||
|
remote: remoteName,
|
||||||
|
publicKey: settings.sshPublicKey,
|
||||||
|
privateKey: settings.sshPrivateKey,
|
||||||
|
password: settings.sshPassword,
|
||||||
|
);
|
||||||
|
} on GitException catch (ex, stackTrace) {
|
||||||
|
Log.e("GitDefaultBranch Failed", ex: ex, stacktrace: stackTrace);
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> numChanges() async {
|
Future<int> numChanges() async {
|
||||||
try {
|
try {
|
||||||
var repo = await git.GitRepository.load(gitDirPath);
|
var repo = await git.GitRepository.load(gitDirPath);
|
||||||
|
@ -450,14 +450,14 @@ class Repository with ChangeNotifier {
|
|||||||
|
|
||||||
var repo = await GitRepository.load(repoPath);
|
var repo = await GitRepository.load(repoPath);
|
||||||
var remote = repo.config.remote(remoteName);
|
var remote = repo.config.remote(remoteName);
|
||||||
var remoteBranch = await repo.guessRemoteHead(remoteName);
|
var remoteBranchName = await _gitRepo.defaultBranch(remoteName);
|
||||||
var remoteBranchName =
|
var remoteBranch = await repo.remoteBranch(remoteName, remoteBranchName);
|
||||||
remoteBranch != null ? remoteBranch.name.branchName() : "master";
|
Log.i("Using remote branch: $remoteBranchName");
|
||||||
|
|
||||||
var branches = await repo.branches();
|
var branches = await repo.branches();
|
||||||
if (branches.isEmpty) {
|
if (branches.isEmpty) {
|
||||||
Log.i("Completing - no local branch");
|
Log.i("Completing - no local branch");
|
||||||
if (remoteBranch != null) {
|
if (remoteBranchName != null && remoteBranchName.isNotEmpty) {
|
||||||
await repo.checkoutBranch(remoteBranchName, remoteBranch.hash);
|
await repo.checkoutBranch(remoteBranchName, remoteBranch.hash);
|
||||||
}
|
}
|
||||||
await repo.setUpstreamTo(remote, remoteBranchName);
|
await repo.setUpstreamTo(remote, remoteBranchName);
|
||||||
|
@ -458,7 +458,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: "2598c4cf21c4e23639b7eb5f3e1dd66cfd8eccd9"
|
resolved-ref: b6ae8855561bfe82b82417f9251917e1f29740a0
|
||||||
url: "https://github.com/GitJournal/git_bindings.git"
|
url: "https://github.com/GitJournal/git_bindings.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.18"
|
version: "0.0.18"
|
||||||
|
Reference in New Issue
Block a user