• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MerginMaps / input / 5983636709

26 Aug 2023 07:50AM UTC coverage: 62.064% (+1.1%) from 60.955%
5983636709

push

github

web-flow
Lcov to lnx (#2772)

move lcov to linux tests

7552 of 12168 relevant lines covered (62.06%)

102.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.3
/core/project.cpp
1
/***************************************************************************
2
 *                                                                         *
3
 *   This program is free software; you can redistribute it and/or modify  *
4
 *   it under the terms of the GNU General Public License as published by  *
5
 *   the Free Software Foundation; either version 2 of the License, or     *
6
 *   (at your option) any later version.                                   *
7
 *                                                                         *
8
 ***************************************************************************/
9

10
#include "project.h"
11
#include "merginapi.h"
12
#include "coreutils.h"
13

14
QString LocalProject::id() const
19,001✔
15
{
16
  return fullName();
19,001✔
17
}
18

19
QString LocalProject::fullName() const
19,056✔
20
{
21
  if ( !projectName.isEmpty() && !projectNamespace.isEmpty() )
19,056✔
22
    return MerginApi::getFullProjectName( projectNamespace, projectName );
18,403✔
23

24
  if ( projectDir.isEmpty() )
653✔
25
    return QString();
103✔
26

27
  QDir dir( projectDir );
550✔
28
  return dir.dirName();
550✔
29
}
550✔
30

31
QString MerginProject::id() const
25,113✔
32
{
33
  return MerginApi::getFullProjectName( projectNamespace, projectName );
25,113✔
34
}
35

36
ProjectStatus::Status ProjectStatus::projectStatus( const Project &project )
374✔
37
{
38
  if ( !project.isMergin() || !project.isLocal() ) // This is not a Mergin project or not downloaded project
374✔
39
    return ProjectStatus::NoVersion;
48✔
40

41
  // There was no sync yet
42
  if ( !project.local.hasMerginMetadata() )
326✔
43
  {
44
    return ProjectStatus::NoVersion;
14✔
45
  }
46

47
  if ( ProjectStatus::hasLocalChanges( project.local ) )
312✔
48
  {
49
    return ProjectStatus::Modified;
19✔
50
  }
51

52
  // Version is lower than latest one, last sync also before updated
53
  if ( project.local.localVersion < project.mergin.serverVersion )
293✔
54
  {
55
    return ProjectStatus::OutOfDate;
2✔
56
  }
57

58
  return ProjectStatus::UpToDate;
291✔
59
}
60

61
bool ProjectStatus::hasLocalChanges( const LocalProject &project )
313✔
62
{
63
  QString metadataFilePath = project.projectDir + "/" + MerginApi::sMetadataFile;
313✔
64

65
  if ( !QFile::exists( metadataFilePath ) )
313✔
66
  {
67
    // If the project does not have metadata file, there are local changes
68
    return true;
×
69
  }
70

71
  // Check if something has locally changed after last sync with server
72
  QDateTime lastModified = CoreUtils::getLastModifiedFileDateTime( project.projectDir );
313✔
73

74
  QDateTime lastSync = QFileInfo( metadataFilePath ).lastModified().toUTC();
626✔
75
  MerginProjectMetadata metadata = MerginProjectMetadata::fromCachedJson( metadataFilePath );
313✔
76

77
  int filesCount = CoreUtils::getProjectFilesCount( project.projectDir );
313✔
78

79
  if ( lastSync < lastModified || metadata.files.count() != filesCount )
313✔
80
  {
81
    // When GPKG is opened, its header is updated and therefore lastModified timestamp is updated as well.
82
    // Double check if something has really changed
83
    ProjectDiff diff = MerginApi::localProjectChanges( project.projectDir );
24✔
84

85
    if ( !diff.localAdded.isEmpty() || !diff.localUpdated.isEmpty() || !diff.localDeleted.isEmpty() )
24✔
86
      return true;
20✔
87
  }
24✔
88

89
  return false;
293✔
90
}
313✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc