检查git子模块是否已在远程上更新

时间:2018-06-21 09:28:45

标签: git cmake

我想在我的cmake脚本中添加一个检查,以检查远程子模块存储库的头部是否已更新。到目前为止,我只在脚本中运行过 import {Component, OnInit, ViewChild} from '@angular/core'; import {MatTableDataSource, MatPaginator, MatSort} from '@angular/material'; import {AppService} from '../../../app.service'; import {NavigationExtras, Router} from '@angular/router'; import {ConfirmationService} from "primeng/api"; import {AppComponent} from "../../../app.component"; import {FullLayoutComponent} from "../../../layout/full_layout.component"; @Component({ selector: 'app-user-list', templateUrl: './user-list.component.html', styleUrls: ['./user-list.component.scss'] }) export class UserListComponent implements OnInit { displayedColumns = ['id', 'full_name', 'mobile', 'email', 'organization', 'status' ]; dataSource: any; @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; private employeeTemp: any; constructor( private appService: AppService, private _router: Router, private confirmationService: ConfirmationService, private flashMsg: FullLayoutComponent , ) { } ngOnInit() { this.appService.getUserDataList().subscribe(res => { this.employeeTemp = res; this.dataSource = new MatTableDataSource(this.employeeTemp); this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; } ); } applyFilter(filterValue: string) { filterValue = filterValue.trim(); // Remove whitespace filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches this.dataSource.filter = filterValue; } public editUserData(item) { const navigationExtras: NavigationExtras = { queryParams: { 'qsUserId': item.id }, fragment: 'anchor', }; this._router.navigate([ 'user/edit' ], navigationExtras); } public viewUserData(item) { const navigationExtras: NavigationExtras = { queryParams: { 'qsUserId': item.id }, fragment: 'anchor', }; this._router.navigate([ 'user/view' ], navigationExtras); } confirmDelete(item) { this.confirmationService.confirm({ message: 'Are you sure you want to delete this Employee?', header: 'Confirmation', accept: () => { this.appService.deleteUser(item.id).subscribe(res => { // Splice Or something so the page doesnt reload but the data gets removed from the view. this.employeeTemp = this.employeeTemp.filter(employee => employee.id != item.id) this.dataSource = new MatTableDataSource(this.employeeTemp); this.flashMsg.flashMsg('success', 'Deleted', 'User has been deleted.'); // this.EmployeeListComponent(); }, err => { this.flashMsg.flashMsg('error', 'Error', 'User has not been deleted.'); }); }, reject: () => { }, }); } } ,但是如果更新了远程子模块,则可能会导致意外更改。 有没有一种好方法可以检查远程头是否在本地子模块的头前面进行了几次提交,而又不更改本地子模块的状态?

1 个答案:

答案 0 :(得分:1)

基于https://stackoverflow.com/a/3278427/7976758,我将执行以下操作:

git submodule foreach git remote update
git submodule foreach git --no-pager diff origin/master master

如果子模块使用不同的分支,则脚本需要将其考虑在内。