-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Group local branch tip with its remotes into one bubble
if they are on the same commit. Only if it's safe to do so, i.e. there are no tags or stashes with the same name. Two remotes without the local one also won't be grouped. Grouping can be deactivated by setting `{ "git-log--graph.group-branch-remotes": false }`
- Loading branch information
Showing
6 changed files
with
72 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<template> | ||
<div class="commit-ref-tips row align-center"> | ||
<ref-tip v-for="ref of refs" :key="ref.id" :commit="commit" :git_ref="ref" /> | ||
</div> | ||
</template> | ||
<script setup> | ||
import { computed } from 'vue' | ||
import { config } from '../state/store' | ||
let props = defineProps({ | ||
commit: { | ||
required: true, | ||
/** @type {Vue.PropType<Commit>} */ | ||
type: Object, | ||
}, | ||
}) | ||
function group_same_name_branches_into_one(/** @type {Branch[]} */ branches) { | ||
return { | ||
...branches[0], | ||
remote_name: undefined, | ||
id: branches[0].name, | ||
remote_names_group: branches | ||
.map(ref => ref.remote_name) | ||
.filter(is_truthy), | ||
} | ||
} | ||
let refs = computed(() => { | ||
if (config.value['group-branch-remotes'] === false) | ||
return props.commit.refs | ||
return Object.values(props.commit.refs.reduce((/** @type {Record<string, GitRef[]>} */ all, ref) => { | ||
all[ref.name] ||= [] | ||
all[ref.name].push(ref) | ||
return all | ||
}, {})) | ||
.map(name_group => { | ||
let as_branches = name_group.filter(is_branch) | ||
let is_all_branches = as_branches.length === name_group.length | ||
let has_local_branch_tip = as_branches.some(branch => ! branch.remote_name) | ||
if (as_branches.length > 1 && is_all_branches && has_local_branch_tip) | ||
return group_same_name_branches_into_one(as_branches) | ||
return name_group | ||
}).flat() | ||
}) | ||
</script> | ||
<style scoped> | ||
.commit-ref-tips { | ||
line-height: 1em; | ||
z-index: 1; | ||
} | ||
</style> |
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