mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cloud-storage: simplify creation of git authorship
While having the local user information in the repo on Linux seemed clever when we implemented it, it's inconsistent with all the other platforms. Let's just not do that unless the user has indeed set a global name/email pair for git. Instead indicate if this was Subsurface or Subsurface-mobile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
67a717dc05
commit
7a238b6146
7 changed files with 7 additions and 65 deletions
|
@ -53,9 +53,6 @@ bool subsurface_ignore_font(const char *font)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subsurface_user_info(struct user_info *user)
|
|
||||||
{ /* Encourage use of at least libgit2-0.20 */ }
|
|
||||||
|
|
||||||
static const char *system_default_path_append(const char *append)
|
static const char *system_default_path_append(const char *append)
|
||||||
{
|
{
|
||||||
// Qt appears to find a working path for us - let's just go with that
|
// Qt appears to find a working path for us - let's just go with that
|
||||||
|
|
|
@ -322,12 +322,6 @@ extern int save_dive_sites_logic(const char *filename, const struct dive_site *s
|
||||||
struct membuffer;
|
struct membuffer;
|
||||||
extern void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize);
|
extern void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize);
|
||||||
|
|
||||||
struct user_info {
|
|
||||||
char *name;
|
|
||||||
char *email;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern void subsurface_user_info(struct user_info *);
|
|
||||||
extern void subsurface_console_init(void);
|
extern void subsurface_console_init(void);
|
||||||
extern void subsurface_console_exit(void);
|
extern void subsurface_console_exit(void);
|
||||||
extern bool subsurface_user_is_root(void);
|
extern bool subsurface_user_is_root(void);
|
||||||
|
|
|
@ -37,11 +37,6 @@ bool subsurface_ignore_font(const char*)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subsurface_user_info(struct user_info *)
|
|
||||||
{
|
|
||||||
// We use of at least libgit2-0.20
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *system_default_path_append(const char *append)
|
static const char *system_default_path_append(const char *append)
|
||||||
{
|
{
|
||||||
// Qt appears to find a working path for us - let's just go with that
|
// Qt appears to find a working path for us - let's just go with that
|
||||||
|
|
|
@ -20,12 +20,6 @@
|
||||||
#include <zip.h>
|
#include <zip.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
void subsurface_user_info(struct user_info *info)
|
|
||||||
{
|
|
||||||
UNUSED(info);
|
|
||||||
/* Nothing, let's use libgit2-20 on MacOS */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* macos defines CFSTR to create a CFString object from a constant,
|
/* macos defines CFSTR to create a CFString object from a constant,
|
||||||
* but no similar macros if a C string variable is supposed to be
|
* but no similar macros if a C string variable is supposed to be
|
||||||
* the argument. We add this here (hardcoding the default allocator
|
* the argument. We add this here (hardcoding the default allocator
|
||||||
|
|
|
@ -1024,19 +1024,14 @@ static int get_authorship(git_repository *repo, git_signature **authorp)
|
||||||
{
|
{
|
||||||
if (git_signature_default(authorp, repo) == 0)
|
if (git_signature_default(authorp, repo) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
/* try to fetch the user info from the OS, otherwise use default values. */
|
|
||||||
struct user_info user = { .name = NULL, .email = NULL };
|
|
||||||
subsurface_user_info(&user);
|
|
||||||
if (!user.name || !*user.name)
|
|
||||||
user.name = strdup("Subsurface");
|
|
||||||
if (!user.email)
|
|
||||||
user.email = strdup("subsurface-app-account@subsurface-divelog.org");
|
|
||||||
|
|
||||||
/* git_signature_default() is too recent */
|
#ifdef SUBSURFACE_MOBILE
|
||||||
int ret = git_signature_now(authorp, user.name, user.email);
|
#define APPNAME "Subsurface-mobile"
|
||||||
free((void *)user.name);
|
#else
|
||||||
free((void *)user.email);
|
#define APPNAME "Subsurface"
|
||||||
return ret;
|
#endif
|
||||||
|
return git_signature_now(authorp, APPNAME, "subsurface-app-account@subsurface-divelog.org");
|
||||||
|
#undef APPNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_commit_message(struct membuffer *msg, bool create_empty)
|
static void create_commit_message(struct membuffer *msg, bool create_empty)
|
||||||
|
|
30
core/unix.c
30
core/unix.c
|
@ -34,36 +34,6 @@ bool subsurface_ignore_font(const char *font)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subsurface_user_info(struct user_info *user)
|
|
||||||
{
|
|
||||||
struct passwd *pwd = getpwuid(getuid());
|
|
||||||
const char *username = getenv("USER");
|
|
||||||
|
|
||||||
if (pwd) {
|
|
||||||
if (!empty_string(pwd->pw_gecos)) {
|
|
||||||
user->name = strdup(pwd->pw_gecos);
|
|
||||||
// We only want the name, not the office or phone number
|
|
||||||
char *c = user->name;
|
|
||||||
while (*c) {
|
|
||||||
if (*c == ',') {
|
|
||||||
*c = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!username)
|
|
||||||
username = pwd->pw_name;
|
|
||||||
}
|
|
||||||
if (!empty_string(username)) {
|
|
||||||
char hostname[64];
|
|
||||||
struct membuffer mb = {};
|
|
||||||
gethostname(hostname, sizeof(hostname));
|
|
||||||
put_format(&mb, "%s@%s", username, hostname);
|
|
||||||
user->email = detach_cstring(&mb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *system_default_path_append(const char *append)
|
static const char *system_default_path_append(const char *append)
|
||||||
{
|
{
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
|
|
|
@ -23,9 +23,6 @@ const char current_system_divelist_default_font[] = "Segoe UI";
|
||||||
const char *system_divelist_default_font = non_standard_system_divelist_default_font;
|
const char *system_divelist_default_font = non_standard_system_divelist_default_font;
|
||||||
double system_divelist_default_font_size = -1;
|
double system_divelist_default_font_size = -1;
|
||||||
|
|
||||||
void subsurface_user_info(struct user_info *user)
|
|
||||||
{ /* Encourage use of at least libgit2-0.20 */ }
|
|
||||||
|
|
||||||
extern bool isWin7Or8();
|
extern bool isWin7Or8();
|
||||||
|
|
||||||
void subsurface_OS_pref_setup(void)
|
void subsurface_OS_pref_setup(void)
|
||||||
|
|
Loading…
Add table
Reference in a new issue